use of android.app.NotificationManager in project leakcanary by square.
the class LeakCanaryInternals method showNotification.
public static void showNotification(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent pendingIntent, int notificationId) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification;
Notification.Builder builder = //
new Notification.Builder(context).setSmallIcon(R.drawable.leak_canary_notification).setWhen(System.currentTimeMillis()).setContentTitle(contentTitle).setContentText(contentText).setAutoCancel(true).setContentIntent(pendingIntent);
if (SDK_INT < JELLY_BEAN) {
notification = builder.getNotification();
} else {
notification = builder.build();
}
notificationManager.notify(notificationId, notification);
}
use of android.app.NotificationManager in project NotificationPeekPort by lzanita09.
the class MainActivity method sendTestNotification.
/**
* Lock device screen and send test notification.
*/
private void sendTestNotification() {
final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
Handler handler = new Handler(getMainLooper());
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
final Notification.Builder builder = new Notification.Builder(this);
builder.setSmallIcon(R.drawable.ic_launcher).setTicker(getString(R.string.diagnosis_notification_title)).setContentTitle(getString(R.string.diagnosis_notification_title_content)).setContentText(getString(R.string.diagnosis_notification_content)).setLights(Color.GREEN, 1000, 5000).setAutoCancel(true).setContentIntent(pendingIntent);
handler.postDelayed(new Runnable() {
@Override
public void run() {
devicePolicyManager.lockNow();
}
}, LOCK_SCREEN_DELAY);
handler.postDelayed(new Runnable() {
@Override
public void run() {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(TEST_ID, builder.build());
finish();
}
}, SEND_NOTIFICATION_DELAY);
}
use of android.app.NotificationManager in project AndroidDevMetrics by frogermcs.
the class AndroidDevMetrics method showNotification.
private void showNotification() {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_timeline_white_18dp).setContentTitle(context.getString(R.string.adm_name)).setContentText("Click to see current metrics").setAutoCancel(autoCancelNotification);
Intent resultIntent = new Intent(context, MetricsActivity.class);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify("AndroidDevMetrics".hashCode(), mBuilder.build());
}
use of android.app.NotificationManager in project benCoding.AlarmManager by benbahrenburg.
the class AlarmManagerProxy method cancelNotification.
@Kroll.method
public void cancelNotification(int requestCode) {
NotificationManager notificationManager = (NotificationManager) TiApplication.getInstance().getSystemService(TiApplication.NOTIFICATION_SERVICE);
notificationManager.cancel(requestCode);
}
use of android.app.NotificationManager in project coursera-android by aporter.
the class NotificationStatusBarWithCustomViewActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mNotificationIntent = new Intent(getApplicationContext(), NotificationSubActivity.class);
mContentIntent = PendingIntent.getActivity(getApplicationContext(), 0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Define the Notification's expanded message and Intent:
mContentView.setTextViewText(R.id.text, contentText + " (" + ++mNotificationCount + ")");
// Build the Notification
Notification.Builder notificationBuilder = new Notification.Builder(getApplicationContext()).setTicker(tickerText).setSmallIcon(android.R.drawable.stat_sys_warning).setAutoCancel(true).setContentIntent(mContentIntent).setSound(soundURI).setVibrate(mVibratePattern).setContent(mContentView);
// Pass the Notification to the NotificationManager:
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(MY_NOTIFICATION_ID, notificationBuilder.build());
}
});
}
Aggregations