基本上,我正在浏览互联网或查看其他应用。我收到一条通知,打开我的应用程序。我做了一些东西,它完成。我的应用程序关闭,我回到了启动器。我如何让我的应用程序完成并将我返回到之前浏览过的任何应用程序/ Chrome页面?Android - 当我的应用完成后恢复后台应用
AndroidManifest节这个活动:
<activity
android:name=".AcceptRejectActivity"
android:label="@string/title_activity_accept_reject"
android:screenOrientation="portrait" >
</activity>
通知码:
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent resultIntent = new Intent(this, AcceptRejectActivity.class);
resultIntent.putExtra("message","Do you choose to accept this message?");
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(AcceptRejectActivity.class);
// Adds the Intent that starts the Activity to the top of the stack //
stackBuilder.addNextIntent(resultIntent);
PendingIntent contentIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
String msg = "You have a message"
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_logo)
.setContentTitle("Message")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg)
.setPriority(Notification.PRIORITY_HIGH);
mBuilder.setContentIntent(contentIntent);
mBuilder.setAutoCancel(true);
android.app.Notification note = mBuilder.build();
note.defaults |= android.app.Notification.DEFAULT_VIBRATE;
note.defaults |= android.app.Notification.DEFAULT_SOUND;
mNotificationManager.notify(0, note);
片段的关闭功能
private void allDone() {
Log.i(TAG, "The choice has been made");
getActivity().finish();
//NavUtils.navigateUpFromSameTask(getActivity());
}
是的,这有点奇怪。调用完成()使用关闭我的应用程序,并返回到我的任何应用程序。有点像跨应用onbackpressed。然后有一天它停止工作。 这次重新启动chrome,但没有使我回到当前页面。如果我在脸书,收件箱或任何其他应用程序中仍然无法解决问题。 – ChoklatStu
这会告诉你最后一个打开的页面在chrome中,如果你想打开一个特定的页面,只需添加url,例如:?url = http://www.facebook.com – Jorgesys