List of usage examples for android.app NotificationManager notify
public void notify(int id, Notification notification)
From source file:at.ac.uniklu.mobile.sportal.notification.GCMCampusService.java
private void notifyUser() { try {//from w w w . jav a2 s . c om NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); // get all notifications since last check time List<Notification> notifications = Studentportal.getSportalClient() .getNotifications(Preferences.getNotificationsLastCheckDate(this, preferences)); // set last check time to current time Preferences.setNotificationsLastCheckDate(this, preferences, new Date()); Collections.reverse(notifications); for (Notification n : notifications) { Log.i(TAG, n.toString()); String title = n.getName(); String text = null; Intent i = null; switch (n.getType()) { case UNKNOWN: // skip unknown notification (might be a new type for a newer app version) continue; case INSKRIPTION: text = getString(R.string.notification_inskription); break; case LV_AUFGENOMMEN: text = getString(R.string.notification_lv_aufgenommen); Studentportal.getSportalClient().clearLehrveranstaltungen(); i = new Intent(this, CourseListActivity.class); break; case LV_STATUS: text = getString(R.string.notification_lv_status) + " " + n.getValue(); Studentportal.getSportalClient().clearLehrveranstaltungen(); i = new Intent(this, CourseListActivity.class); break; case LV_UMMELDUNG: text = getString(R.string.notification_lv_ummeldung) + " " + n.getValue(); Studentportal.getSportalClient().clearLehrveranstaltungen(); i = new Intent(this, CourseListActivity.class); break; case PRUEFUNG_ANMELDUNG: text = getString(R.string.notification_pruefung_anmeldung); Studentportal.getSportalClient().clearPruefungen(); i = new Intent(this, ExamListActivity.class); break; case NOTE_NEU: text = getString(R.string.notification_note_neu) + " " + n.getValue(); Studentportal.getSportalClient().clearNoten(); i = new Intent(this, GradeListActivity.class); break; case STUDIUM_ABSCHLUSS: text = getString(R.string.notification_studium_abschluss); break; case STUDIUM_ABSCHNITTSABSCHLUSS: text = getString(R.string.notification_studium_abschnittsabschluss); break; case STUDIUM_STEOPERFUELLT: text = getString(R.string.notification_steoperfuellt); break; } NotificationCompat.Builder nb = GCMUtils.getDefaultNotification(this); nb.setTicker(title); nb.setContentTitle(title); nb.setContentText(text); if (i == null) { /* intent must not be null on Android 2.3, even if the notification * doesn't do anything when selected; else, an exception gets thrown: * java.lang.IllegalArgumentException: contentIntent required */ i = new Intent(); } /* Pass System.currentTimeMillis() as requestId to make every pending intent unique. Otherwise, * they would overwrite each other if the intent is the same and not all notification (if shown * at the same time) would trigger the desired action when selected. */ nb.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(), i, Intent.FLAG_ACTIVITY_NEW_TASK)); notificationManager.notify(Studentportal.NOTIFICATION_GCM_NOTIFICATION + n.getType().ordinal(), nb.build()); } } catch (Exception e) { Analytics.onError(Analytics.ERROR_NOTIFICATIONS_REQUEST, e); } }
From source file:com.android.mms.transaction.MessagingNotification.java
public static void blockingUpdateNewIccMessageIndicator(Context context, String address, String message, int subId, long timeMillis) { final Notification.Builder noti = new Notification.Builder(context).setWhen(timeMillis); Contact contact = Contact.get(address, false); NotificationInfo info = getNewIccMessageNotificationInfo(context, true /* isSms */, address, message, null /* subject */, subId, timeMillis, null /* attachmentBitmap */, contact, WorkingMessage.TEXT); noti.setSmallIcon(R.drawable.stat_notify_sms); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context); // Update the notification. PendingIntent pendingIntent;//from ww w . j a v a 2 s .c om if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { pendingIntent = PendingIntent.getActivity(context, 0, info.mClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); } else { // Use requestCode to avoid updating all intents of previous notifications pendingIntent = PendingIntent.getActivity(context, ICC_NOTIFICATION_ID_BASE + subId, info.mClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); } String title = info.mTitle; noti.setContentTitle(title).setContentIntent(pendingIntent) //taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)) .setCategory(Notification.CATEGORY_MESSAGE).setPriority(Notification.PRIORITY_DEFAULT); int defaults = 0; SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); boolean vibrate = false; if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) { // The most recent change to the vibrate preference is to store a boolean // value in NOTIFICATION_VIBRATE. If prefs contain that preference, use that // first. vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false); } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) { // This is to support the pre-JellyBean MR1.1 version of vibrate preferences // when vibrate was a tri-state setting. As soon as the user opens the Messaging // app's settings, it will migrate this setting from NOTIFICATION_VIBRATE_WHEN // to the boolean value stored in NOTIFICATION_VIBRATE. String vibrateWhen = sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null); vibrate = "always".equals(vibrateWhen); } if (vibrate) { defaults |= Notification.DEFAULT_VIBRATE; } String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null); noti.setSound(TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr)); Log.d(TAG, "blockingUpdateNewIccMessageIndicator: adding sound to the notification"); defaults |= Notification.DEFAULT_LIGHTS; noti.setDefaults(defaults); // set up delete intent noti.setDeleteIntent(PendingIntent.getBroadcast(context, 0, sNotificationOnDeleteIntent, 0)); final Notification notification; // This sets the text for the collapsed form: noti.setContentText(info.formatBigMessage(context)); if (info.mAttachmentBitmap != null) { // The message has a picture, show that notification = new Notification.BigPictureStyle(noti).bigPicture(info.mAttachmentBitmap) // This sets the text for the expanded picture form: .setSummaryText(info.formatPictureMessage(context)).build(); } else { // Show a single notification -- big style with the text of the whole message notification = new Notification.BigTextStyle(noti).bigText(info.formatBigMessage(context)).build(); } notifyUserIfFullScreen(context, title); nm.notify(ICC_NOTIFICATION_ID_BASE + subId, notification); }
From source file:com.akop.bach.service.XboxLiveServiceClient.java
private void notifyBeacons(XboxLiveAccount account, HashMap<String, long[]> matching, HashMap<String, long[]> lastMatching) { Context context = getContext(); NotificationManager mgr = getNotificationManager(); if (App.getConfig().logToConsole()) { if (lastMatching != null && lastMatching.size() > 0) { App.logv("Last matching:"); for (String key : lastMatching.keySet()) { String s = "* BEACONS " + key + ": "; for (long friendId : lastMatching.get(key)) s += friendId + ","; App.logv(s);/* www . j a va 2 s . c o m*/ } } if (matching.size() > 0) { App.logv("Now matching:"); for (String key : matching.keySet()) { String s = "* BEACONS " + key + ": "; for (long friendId : matching.get(key)) s += friendId + ","; App.logv(s); } } } int notificationId = 0x40000 | (((int) account.getId() & 0xfff) << 4); String[] gameUids = new String[matching.keySet().size()]; matching.keySet().toArray(gameUids); for (int i = 0; i < MAX_BEACONS; i++) { if (i < gameUids.length) { String gameUid = gameUids[i]; long[] matchingFriends = matching.get(gameUid); if (!lastMatching.containsKey(gameUid) || !areArraysEquivalent(matchingFriends, lastMatching.get(gameUid))) { if (matchingFriends.length > 0) { String title = XboxLive.Games.getTitle(context, account, gameUid); String message = null; String ticker = null; int iconOverlayNumber = 0; Intent intent = null; if (matchingFriends.length > 1) { iconOverlayNumber = matchingFriends.length; intent = new Intent(context, FriendList.class); intent.putExtra("account", account); ticker = context.getString(R.string.friends_playing_beaconed_game_title_f, matchingFriends.length, title); message = context.getString(R.string.friends_playing_beaconed_game_f, matchingFriends.length, account.getDescription()); } else { String friendScreenName = Friends.getGamertag(context, matchingFriends[0]); intent = account.getFriendIntent(context, friendScreenName); ticker = context.getString(R.string.friend_playing_beaconed_game_title_f, friendScreenName, title); message = context.getString(R.string.friend_playing_beaconed_game_f, friendScreenName, account.getDescription()); } NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)) .setSmallIcon(R.drawable.xbox_stat_notify_beacon).setContentTitle(title) .setContentText(message).setTicker(ticker).setWhen(System.currentTimeMillis()) .setAutoCancel(true).setOnlyAlertOnce(true).setNumber(iconOverlayNumber) .setLights(DEFAULT_LIGHTS_COLOR, DEFAULT_LIGHTS_ON_MS, DEFAULT_LIGHTS_OFF_MS) .setSound(account.getRingtoneUri()); if (account.isVibrationEnabled()) builder.setDefaults(Notification.DEFAULT_VIBRATE); Notification notification = builder.getNotification(); mgr.notify(notificationId, notification); } else { mgr.cancel(notificationId); } } } else { mgr.cancel(notificationId); } notificationId++; } }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
private void SendNotification(String tickerText, String expandedText) { NotificationManager notificationManager = (NotificationManager) contextWrapper .getSystemService(Context.NOTIFICATION_SERVICE); int icon = R.drawable.ateamlogo; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= (Notification.FLAG_INSISTENT | Notification.FLAG_AUTO_CANCEL); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_LIGHTS; Context context = contextWrapper.getApplicationContext(); // Intent to launch an activity when the extended text is clicked Intent intent2 = new Intent(contextWrapper, SUTAgentAndroid.class); PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent2, 0); notification.setLatestEventInfo(context, tickerText, expandedText, launchIntent); notificationManager.notify(1959, notification); }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
protected void notifyCompleted(HashMap completedTorrents) { Intent intent = new Intent(this, MainActivity.class); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); // build notification // the addAction re-use the same intent to keep the example short Notification.Builder builder = new Notification.Builder(this).setContentTitle("qBittorrent") .setContentText("Torrent(s) completed").setSmallIcon(R.drawable.ic_stat_completed) .setNumber(completedTorrents.size()).setContentIntent(pIntent).setAutoCancel(true); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification;/* w w w . j av a 2 s . co m*/ notification = builder.getNotification(); notificationManager.notify(0, notification); }
From source file:com.ibm.mobilefirstplatform.clientsdk.android.push.api.MFPPushIntentService.java
private void generateNotification(Context context, String ticker, String title, String msg, int icon, Intent intent, String sound, int notificationId, MFPInternalPushMessage message) { int androidSDKVersion = Build.VERSION.SDK_INT; long when = System.currentTimeMillis(); Notification notification = null; NotificationCompat.Builder builder = new NotificationCompat.Builder(this); if (message.getGcmStyle() != null && androidSDKVersion > 21) { NotificationCompat.Builder mBuilder = null; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); try {//from w w w. j av a2 s.c om JSONObject gcmStyleObject = new JSONObject(message.getGcmStyle()); String type = gcmStyleObject.getString(TYPE); if (type != null && type.equalsIgnoreCase(PICTURE_NOTIFICATION)) { Bitmap remote_picture = null; NotificationCompat.BigPictureStyle notificationStyle = new NotificationCompat.BigPictureStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); try { remote_picture = new getBitMapBigPictureNotification() .execute(gcmStyleObject.getString(URL)).get(); } catch (Exception e) { logger.error( "MFPPushIntentService:generateNotification() - Error while fetching image file."); } if (remote_picture != null) { notificationStyle.bigPicture(remote_picture); } mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setLargeIcon(remote_picture).setAutoCancel(true) .setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } else if (type != null && type.equalsIgnoreCase(BIGTEXT_NOTIFICATION)) { NotificationCompat.BigTextStyle notificationStyle = new NotificationCompat.BigTextStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); notificationStyle.bigText(gcmStyleObject.getString(TEXT)); mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setAutoCancel(true).setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } else if (type != null && type.equalsIgnoreCase(INBOX_NOTIFICATION)) { NotificationCompat.InboxStyle notificationStyle = new NotificationCompat.InboxStyle(); notificationStyle.setBigContentTitle(ticker); notificationStyle.setSummaryText(gcmStyleObject.getString(TITLE)); String lines = gcmStyleObject.getString(LINES).replaceAll("\\[", "").replaceAll("\\]", ""); String[] lineArray = lines.split(","); for (String line : lineArray) { notificationStyle.addLine(line); } mBuilder = new NotificationCompat.Builder(context); notification = mBuilder.setSmallIcon(icon).setAutoCancel(true).setContentTitle(title) .setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentText(msg).setStyle(notificationStyle).build(); } notification.flags = Notification.FLAG_AUTO_CANCEL; notificationManager.notify(notificationId, notification); } catch (JSONException e) { logger.error("MFPPushIntentService:generateNotification() - Error while parsing JSON."); } } else { if (androidSDKVersion > 10) { builder.setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)).setSmallIcon(icon).setTicker(ticker).setWhen(when) .setAutoCancel(true).setContentTitle(title).setContentText(msg) .setSound(getNotificationSoundUri(context, sound)); if (androidSDKVersion > 15) { int priority = getPriorityOfMessage(message); builder.setPriority(priority); notification = builder.build(); } if (androidSDKVersion > 19) { //As new material theme is very light, the icon is not shown clearly //hence setting the background of icon to black builder.setColor(Color.BLACK); Boolean isBridgeSet = message.getBridge(); if (!isBridgeSet) { // show notification only on current device. builder.setLocalOnly(true); } notification = builder.build(); int receivedVisibility = 1; String visibility = message.getVisibility(); if (visibility != null && visibility.equalsIgnoreCase(MFPPushConstants.VISIBILITY_PRIVATE)) { receivedVisibility = 0; } if (receivedVisibility == Notification.VISIBILITY_PRIVATE && message.getRedact() != null) { builder.setContentIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT)).setSmallIcon(icon).setTicker(ticker) .setWhen(when).setAutoCancel(true).setContentTitle(title) .setContentText(message.getRedact()) .setSound(getNotificationSoundUri(context, sound)); notification.publicVersion = builder.build(); } } if (androidSDKVersion > 21) { String setPriority = message.getPriority(); if (setPriority != null && setPriority.equalsIgnoreCase(MFPPushConstants.PRIORITY_MAX)) { //heads-up notification builder.setContentText(msg).setFullScreenIntent(PendingIntent.getActivity(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification = builder.build(); } } } else { notification = builder .setContentIntent( PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)) .setSmallIcon(icon).setTicker(ticker).setWhen(when).setAutoCancel(true) .setContentTitle(title).setContentText(msg) .setSound(getNotificationSoundUri(context, sound)).build(); } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notification); } }
From source file:edu.mit.viral.shen.DroidFish.java
/** Set/clear the "heavy CPU usage" notification. */ private final void setNotification(boolean show) { if (notificationActive == show) return;/*from w w w . ja v a 2 s.c om*/ notificationActive = show; final int cpuUsage = 1; String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); if (show) { int icon = R.drawable.icon; CharSequence tickerText = getString(R.string.heavy_cpu_usage); long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.flags |= Notification.FLAG_ONGOING_EVENT; Context context = getApplicationContext(); CharSequence contentTitle = getString(R.string.background_processing); CharSequence contentText = getString(R.string.lot_cpu_power); Intent notificationIntent = new Intent(this, CPUWarning.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(cpuUsage, notification); } else { mNotificationManager.cancel(cpuUsage); } }
From source file:com.android.example.notificationshowcase.NotificationService.java
@Override protected void onHandleIntent(Intent intent) { ArrayList<Notification> mNotifications = new ArrayList<Notification>(); NotificationManager noMa = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); int bigtextId = mNotifications.size(); mNotifications.add(makeBigTextNotification(this, 0, bigtextId, System.currentTimeMillis())); int uploadId = mNotifications.size(); long uploadWhen = System.currentTimeMillis(); mNotifications.add(makeUploadNotification(this, 10, uploadWhen)); Notification phoneCall = new NotificationCompat.Builder(this).setContentTitle("Incoming call") .setContentText("Matias Duarte").setLargeIcon(getBitmap(this, R.drawable.matias_hed)) .setSmallIcon(R.drawable.stat_sys_phone_call).setDefaults(Notification.DEFAULT_SOUND) .setPriority(NotificationCompat.PRIORITY_MAX) .setContentIntent(ToastService.getPendingIntent(this, "Clicked on Matias")) .addAction(R.drawable.ic_dial_action_call, "Answer", ToastService.getPendingIntent(this, "call answered")) .addAction(R.drawable.ic_end_call, "Ignore", ToastService.getPendingIntent(this, "call ignored")) .setAutoCancel(true).build(); phoneCall.flags |= Notification.FLAG_INSISTENT; mNotifications.add(phoneCall);// w w w . j a va 2s. c o m mNotifications.add( new NotificationCompat.Builder(this).setContentTitle("Stopwatch PRO").setContentText("Counting up") .setContentIntent(ToastService.getPendingIntent(this, "Clicked on Stopwatch")) .setSmallIcon(R.drawable.stat_notify_alarm).setUsesChronometer(true).build()); mNotifications.add( new NotificationCompat.Builder(this).setContentTitle("J Planning").setContentText("The Botcave") .setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.stat_notify_calendar) .setContentIntent(ToastService.getPendingIntent(this, "Clicked on calendar event")) .setContentInfo("7PM") .addAction(R.drawable.stat_notify_snooze, "+10 min", ToastService.getPendingIntent(this, "snoozed 10 min")) .addAction(R.drawable.stat_notify_snooze_longer, "+1 hour", ToastService.getPendingIntent(this, "snoozed 1 hr")) .addAction(R.drawable.stat_notify_email, "Email", makeEmailIntent(this, "gabec@example.com,mcleron@example.com,dsandler@example.com")) .build()); BitmapDrawable d = (BitmapDrawable) getResources().getDrawable(R.drawable.romainguy_rockaway); mNotifications.add(new NotificationCompat.BigPictureStyle(new NotificationCompat.Builder(this) .setContentTitle("Romain Guy") .setContentText("I was lucky to find a Canon 5D Mk III at a local Bay Area " + "store last week but I had not been able to try it in the field " + "until tonight. After a few days of rain the sky finally cleared " + "up. Rockaway Beach did not disappoint and I was finally able to " + "see what my new camera feels like when shooting landscapes.") .setSmallIcon(R.drawable.ic_stat_gplus) .setContentIntent(ToastService.getPendingIntent(this, "Clicked on bigPicture")) .setLargeIcon(getBitmap(this, R.drawable.romainguy_hed)) .addAction(R.drawable.add, "Add to Gallery", ToastService.getPendingIntent(this, "added! (just kidding)")) .setSubText("talk rocks!")).bigPicture(d.getBitmap()).build()); // Note: this may conflict with real email notifications StyleSpan bold = new StyleSpan(Typeface.BOLD); SpannableString line1 = new SpannableString("Alice: hey there!"); line1.setSpan(bold, 0, 5, 0); SpannableString line2 = new SpannableString("Bob: hi there!"); line2.setSpan(bold, 0, 3, 0); SpannableString line3 = new SpannableString("Charlie: Iz IN UR EMAILZ!!"); line3.setSpan(bold, 0, 7, 0); mNotifications.add(new NotificationCompat.InboxStyle( new NotificationCompat.Builder(this).setContentTitle("24 new messages") .setContentText("You have mail!").setSubText("test.hugo2@gmail.com") .setContentIntent(ToastService.getPendingIntent(this, "Clicked on Email")) .setSmallIcon(R.drawable.stat_notify_email)).setSummaryText("+21 more").addLine(line1) .addLine(line2).addLine(line3).build()); mNotifications .add(new NotificationCompat.Builder(this).setContentTitle("Twitter").setContentText("New mentions") .setContentIntent(ToastService.getPendingIntent(this, "Clicked on Twitter")) .setSmallIcon(R.drawable.twitter_icon).setNumber(15) .setPriority(NotificationCompat.PRIORITY_LOW).build()); for (int i = 0; i < mNotifications.size(); i++) { noMa.notify(NOTIFICATION_ID + i, mNotifications.get(i)); } ProgressService.startProgressUpdater(this, uploadId, uploadWhen, 0); }
From source file:android.app.Activity.java
/** * @hide// ww w . j a v a 2 s .c o m */ private void showMigrateNotification() { boolean flag = false; if (mMigrator == null) { mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator")); } try { /* judge whether this App can migrate */ flag = mMigrator.checkMigratableApp(); } catch (RemoteException e) { Log.d(TAG, "Migrate failed in Dialog"); } if (flag) { Intent intent = new Intent(); intent.setClassName("com.android.migrationmanager", "com.android.migrationmanager.DeviceListDialog"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); /* on tapping, show dialog Activity */ Notification notification = new Notification.Builder(this) .setContentTitle("Migrator in " + getAppName()) .setContentText("start Migration: " + getLocalClassName()) .setSmallIcon(com.android.internal.R.drawable.ic_menu_send).setAutoCancel(true) .setContentIntent(pi).build(); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(Process.myUid(), notification); } }