我想編程我的通知RESUME我的應用程序,而不是簡單地啓動我的應用程序的新實例...我基本上是尋找它做同樣的事情,當Home按鈕被長時間按下和應用程序從那裏恢復。Android:如何從通知恢復應用程序?
這是我目前在做什麼:
void notifyme(String string){
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager)
getSystemService(ns);
int icon = R.drawable.notification_icon; // icon from resources
CharSequence tickerText = string + " Program Running..."; // ticker-text
long when = System.currentTimeMillis(); // notification time
Context context = getApplicationContext(); // application Context
CharSequence contentTitle = *********; // expanded message title
CharSequence contentText = string + " Program Running...";//expanded msg text
Intent notificationIntent = new Intent(this, Main.class);
PendingIntent contentIntent = PendingIntent.getActivity(
this, 0, notificationIntent, 0);
// the next two lines initialize the Notification, using the configurations
// above
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText,
contentIntent);
final int HELLO_ID = 1;
mNotificationManager.notify(HELLO_ID, notification);
}
我猜測,新的原意是問題所在...任何幫助,將不勝感激!
可能重複此屬性:HTTP:// stackoverflow.com/questions/5502427/resume-application-and-stack-from-notification,http://stackoverflow.com/questions/3356095/how-to-bring-android-existing-activity-to-front-via-通知 – Philipp 2013-02-17 04:13:08
這幫了我http://stackoverflow.com/questions/3305088/how-to-make-notification-intent-resume-rather -than-making-a-new-intent/39482464#39482464 – TharakaNirmana 2016-09-14 07:51:25