ANDROID从广播接收器发射活动 [英] Android launch an activity from a broadcast receiver
问题描述
我知道这可能不是最好的做法,但是这是我想做的事情。
I know it may not be best practice but this is what i want to do.
在我的广播接收器被称为 - 开始有不全屏且具有透明背景的新活动 - 这对你当前活动/桌面壁纸的顶部打开
When my broadcast receiver is called - start a new activity which has is not fullscreen and has a transparent background - which opens on top of your current activity / desktop wallpaper.
在code我至今如下:
The code I have so far is as follows:
我创建+调用一个新的活动有:
I create + call a new activity with :
Intent testActivityIntent = new Intent(context, com.andy.tabletsms.work.SMSPopup.class);
testActivityIntent.putExtra("com.andy.tabletsms.message", main.msgs.get(i));
testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
testActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
context.startActivity(testActivityIntent);
和则该活动有一个主题:
And then the activity has a theme of :
安卓主题=@安卓风格/ Theme.Translucent.NoTitleBar
android:theme="@android:style/Theme.Translucent.NoTitleBar"
和活动的code是只是一个简单的布局的沼泽标准的活动。然而当广播接收器开始的活动 - 它出现在当应用程序了开始这是开始的previous活动.....顶部,按照此图所示:
And the code of the activity is just a bog standard activity with a simple layout. However when that broadcast receiver starts the activity - it appears on top of the previous activity which was started when the applicaiton started.....as per this image shows :
推荐答案
这是有关我在previous这里的问题回答了问题:<一href=\"http://stackoverflow.com/questions/4628246/activity-started-from-notification-opened-on-top-of-the-activity-stack/4628441#4628441\">Activity从通知开始打开上的活动栈
This is related to the problem I answered in a previous question here: Activity started from notification opened on top of the activity stack
基本上它是所有关于<一个href=\"http://developer.android.com/guide/topics/manifest/activity-element.html#aff\"><$c$c>android:taskAffinity$c$c>和<一个href=\"http://developer.android.com/guide/topics/manifest/activity-element.html#lmode\"><$c$c>android:launchMode$c$c>
Basically it's all about: android:taskAffinity
and android:launchMode
这篇关于ANDROID从广播接收器发射活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!