从通知中的Andr​​oid启动新活动 [英] Start new activity from notification in android

查看:99
本文介绍了从通知中的Andr​​oid启动新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要开始从状态栏通知,一个活动A当的活动时,已经在前面的话,我要完成这一点,重新开始活动答:我怎样才能做到这一点?

I want to start a Activity A from status bar notification, When the activity A is already in front then i want to finish that and fresh start activity A. How can i do this?

推荐答案

查看关于创建状态栏通知的文件。这无疑涉及使用意图和PendingIntent从通知开始和活动。

Review the documentation on creating Status Bar Notifications. This definitely covers starting and Activity from a Notification using an Intent and PendingIntent.

http://developer.android.com/guide/topics/ UI /通知者/ notifications.html

至于如果该活动已经在运行,完成它和新鲜的开始吧...我不知道,可以很容易地完成,这取决于你真正想要的。您可以做一些与清单中的发射方式活动参数:

As for if the Activity is already running, finish it and start it freshly... I'm not sure that can be done easily, depending on what you really want. You may be able to do something with the launch mode activity parameter in the manifest:

http://developer.android.com/guide/topics/manifest/activity-element.html#lmode

再有你的活动响应(与onNewIntent()最有可能的)和复位本身编程。有可能是这样的:

And then have your activity respond (with onNewIntent() most likely) and "reset" itself programmatically. Possibly with something like this:

Android的重新启动我的活动

这篇关于从通知中的Andr​​oid启动新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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