android – 以與歷史恢復相同的方式恢復我的應用程式
我正在編寫一個用於託管應用程式的SDK.我的SDK會建立一個需要恢復應用程式的通知,就像您按任務按鈕並選擇應用程式一樣,或者長按主頁按鈕並選擇您的應用程式.
這是我一直在努力做的:
PackageManager packageManager = context.getPackageManager(); intent = packageManager.getLaunchIntentForPackage(context.getPackageName()); intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 10, intent, flags); Notification notification = new NotificationCompat.Builder(context). setContentIntent(pendingIntent). ... build(); getNotificationManager().notify(NOTIFICATION_ID, notification);
我在主機應用程式上進行了一次測試,其中一個啟動器活動與午餐模式“預設”(清單中未設定啟動模式),我的sdk還以午餐模式“singleTask”進行了1次活動.
所以我吃午餐了
>啟動我的SDK活動,它在onCreat方法中觸發測試通知.
我按家
>我點選通知.
執行這些步驟後,我希望返回到我的活動,而是開啟主機啟動器活動的另一個例項.我失蹤了什麼我該如何使這項工作?
如果你想從你暫停的地方恢復,那麼刪除標記“NEW_TASK”.它不會做新任務.希望你覺得你的任務很有幫助.
http://stackoverflow.com/questions/32756551/resume-my-application-in-the-same-way-it-resumed-from-history