回到previous屏幕上回应通知后pssed后退按钮

回到previous屏幕上回应通知后pssed后退按钮

本文介绍了回到previous屏幕上回应通知后pssed后退按钮$ P $的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我使用code类似于创建一个简单的通知创建和显示来自网络电话的通知。

问题是,我要响应该通知做的业务,然后在一个后退按钮点击,把previously活跃的活动早在前台活动,与它的背叠完好。这是不管,如果previously活跃的活动是我的应用程序或某人的一部分别人的。

目前它是继产生TaskStackBuilder。领先的IT备份应用程序的层次结构,并输出到主屏幕。这是糟糕的用户界面设计,它使用该设备,迫使他们手工回到自己的应用程序,并花费更多的buttonclicks超过必要打破了工作流程的人的。这也是相当直观。

据官方德兴准则,这是它应该如何工作。我联系到了更高的实施,使后退按钮具有相同的功能了按钮应该有

这也是在众多其他应用程序来实现它的常用方法,其中包括谷歌官方的人(谷歌播放的更新通知,浮现在脑海中),所以必须有一个比较标准的方式来做到这一点。

解决方案

 意向意图=新的意图(getApplicationContext(),MainActivity.class)
//添加Intent.FLAG_ACTIVITY_CLEAR_TASK标志,这将清除所有activitys和
//在顶部展开活动。指本申请的任何其他活动将要运行
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
     要么
//添加Intent.FLAG_ACTIVITY_MULTIPLE_TASK它开始多了一个任务,您的应用程序
//其中,活动将不会被清除;
  .addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
  PendingIntent pendingIntent = PendingIntent.getActivity(上下文,0,意图,0);
  通知N =新生成器(context.getApplicationContext())
                 .setContentTitle(简单的通知标题)
                 .setContentText(简单的信息)
                 .setContentIntent(pendingIntent)
                 .setAutoCancel(真)
                 .addAction(R.drawable.ic_launcher,多,pendingIntent).build();


  NotificationManager notificationManager =(NotificationManager)context.getApplicationContext()getSystemService(Context.NOTIFICATION_SERVICE)。
                                           notificationManager.notify(0,n)的;
 

I am using code similar to Creating a simple notification to create and show a notification from a network call.

The issue is that I want the activity that responds to the notification to do it's business and then on a backbutton click, put the previously active activity back in the foreground, with it's back stack intact. This is regardless of if the previously active activity was part of my app or somebody elses.

Currently it is following the generated TaskStackBuilder. Leading it back up the app hierarchy and out to the home screen. This is bad UI-design as it breaks the work-flow of anyone using the device, forcing them to manually go back to their app and spending more buttonclicks than necessary. It is also rather unintuitive.

According to the official desing guidelines this is how it should work. The implementation I linked to higher up makes back button have the same functionality as up button should have

It is also a common way to implement it in a plethora of other apps, including official google ones (google-play update notifications come to mind), so there must be a relatively standard way to do this.

解决方案
Intent intent = new Intent(getApplicationContext(), MainActivity.class)
//add Intent.FLAG_ACTIVITY_CLEAR_TASK flag this will clear all activitys and
//launched activity at top. Means no other activity of this application will be running
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
     or
// add Intent.FLAG_ACTIVITY_MULTIPLE_TASK which start one more task your applications
//   where activity will not be cleared;
  .addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
  PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
  Notification n  = new Builder(context.getApplicationContext())
                 .setContentTitle("simple notification title")
                 .setContentText("simple message")
                 .setContentIntent(pendingIntent)
                 .setAutoCancel(true)
                 .addAction(R.drawable.ic_launcher, "And more",pendingIntent ).build();


  NotificationManager notificationManager =(NotificationManager) context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
                                           notificationManager.notify(0, n);

这篇关于回到previous屏幕上回应通知后pssed后退按钮$ P $的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:35