ANDROID从广播接收器发射活动接收器、ANDROID

2023-09-06 05:52:35 作者:你住在我心里

我知道这可能不是最好的做法,但是这是我想做的事情。

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这里的问题回答了问题: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

基本上它是所有关于android:taskAffinity和android:launchMode

Basically it's all about: android:taskAffinity and android:launchMode