FLAG_ACTIVITY_REORDER_TO_FRONT忽略 [英] FLAG_ACTIVITY_REORDER_TO_FRONT ignored

查看:224
本文介绍了FLAG_ACTIVITY_REORDER_TO_FRONT忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有项目的列表的FragmentActivity,而当该应用是在背景,可以有一推到该项目列表

I have a FragmentActivity with a list of items, and when the app is in background, there can be a push to that item list.

在这种情况下,我想创建一个状态栏通知和警报的通知使用者。
当用户点击该通知,活动应该要重新排序前,显示在屏幕上同时显示在新项目列表的底部。

when this happens, I want to create a statusbar notification and alert the user on the update.
when the user clicks the notification, the activity should reorder to front and show on the screen while showing the new item at the bottom of a list.

所以我写一个通知管理器,显示了用户设备上:

so I write a notification manager that shows that on the users device:

private static void createNotification(String title, String text,
    String largeIcon, String itemdId, Context mCOntext) {

Bitmap ic = BitmapFactory.decodeResource(mContext.getResources(),
    R.drawable.ic_launcher);
Intent intent = new Intent(mContext, MyFragmentActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.putExtra(MyFragmentActivity.SELECTED_ITEM_LIST_ID, DatabaseHelper
    .getItemListById(listId).getId());
PendingIntent pIntent = PendingIntent.getActivity(mContext, 0, intent,
    0);

Notification noti = new NotificationCompat.Builder(mContext)
    .setContentTitle(title).setContentText(text)
    .setSmallIcon(R.drawable.ic_launcher).setContentIntent(pIntent)
    .setAutoCancel(true).setLargeIcon(ic).build();
noti.defaults |= Notification.DEFAULT_LIGHTS;
noti.defaults |= Notification.DEFAULT_VIBRATE;
noti.sound = Uri.parse("android.resource://"
    + mContext.getPackageName() + "/" + R.raw.user_gets_message);

NotificationManager nm = (NotificationManager) mContext
    .getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(0, noti);
}

唯一的问题是,它似乎忽略我的标志,当我浏览到该片段活动,然后去我家的屏幕(背景应用程序),并获得一推,当我点击该通知,应用程序创建一个新的活性(或片段)和示出了新的,而不是原来的新数据。 (这意味着单击后退按钮打开从历史堆栈相同的活动(或片段)。

The only issue is that it seems to ignore my flag, when I navigate to the fragment activity, and then go to my home screen (background the app), and get a push, when I click on the notification, the app creates a new Activity (or fragment) and shows the new one instead of the original with the new data. (this means that clicking the back button opens the same activity (or fragment) from the history stack.

我重写 onNewIntent 和所有活动的生命周期方法和我看到背部点击,被调用的方法是 MyFragmentActivity.onStart MyFragmentActivity.onResume

I overridden the onNewIntent and all the life cycle methods of the activity and I saw that on back clicked, the methods that are called are the MyFragmentActivity.onStartand the MyFragmentActivity.onResume.

这是它是什么,我做错了什么想法?

any thoughts on what it is that I'm doing wrong?

推荐答案

我认为这个问题是你设置活动启动模式为singleTask其中新增标志<一个href=\"http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_BROUGHT_TO_FRONT\">FLAG_ACTIVITY_BROUGHT_TO_FRONT你的意图,并导致标志FLAG_ACTIVITY_REORDER_TO_FRONT被忽略。

i assume that the problem is that you set the activity launch mode to be singleTask which add the flag FLAG_ACTIVITY_BROUGHT_TO_FRONT to your intent, and it cause the flag FLAG_ACTIVITY_REORDER_TO_FRONT to be ignored.

您需要的启动模式更改为单一的顶部。

you need to change the launch mode to single top.

这篇关于FLAG_ACTIVITY_REORDER_TO_FRONT忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆