use*_*418 24 notifications android instance android-activity
申请(非通缉)行为 -
但是 - 不是原始实例,而是启动新实例(例如,在最新实例中缺少原始文本;当最新实例关闭时,仍然存在具有原始文本的原始实例).
通知方法的代码
Context context = getApplicationContext();
CharSequence contentTitle = "someText1";
CharSequence contentText = "someText2";
Intent notifyIntent = new Intent(Intent.ACTION_MAIN);
notifyIntent.setClass(getApplicationContext(), RadioStream.class);
PendingIntent intent =
PendingIntent.getActivity(RadioStream.this, 0, notifyIntent, 0);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
Run Code Online (Sandbox Code Playgroud)
我也在清单xml文件中跟随标记
android:launchMode="singleTask"
Run Code Online (Sandbox Code Playgroud)
但它仍然是相同的...主要问题是应用程序的双/三初始化,我知道还有其他方法可以保留恢复的应用程序中的值.此外,还需要应用程序在后台运行,因为主要功能是互联网广播流.
代码中缺少什么?我方缺少哪些信息来解决问题?
谢谢!
DAV
ogn*_*ian 21
您所谓的"应用程序"最有可能是一项活动.为了避免重新装入它,请使用
android:launchMode="singleTop"
Run Code Online (Sandbox Code Playgroud)
要让一些代码运行后台,您需要将其视为服务
Com*_*are 13
另一种选择是使用setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP)
你的Intent
.
归档时间: |
|
查看次数: |
12217 次 |
最近记录: |