我真的在推进我的 android 应用程序。我能够执行onDestroy() and onPause()
例程。
我还设法让 Android 的通知服务将带有标题和正文的图标放在通知栏/任务菜单中。
此通知服务的唯一问题是,如果我的 android 应用程序已经在运行,并且已经启动了onPause()
功能super.onPause(); moveTaskToBack(true);
,如果用户点击通知,它将调出我的应用程序的新实例。
一旦用户与新实例交互,由于后台版本已经在运行,程序会崩溃,从而导致冲突。
这是我的通知代码,我需要帮助以使此代码查找我的应用程序的已运行版本:
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificatonManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "app name";
long when = System.currentTimeMillis();
CharSequence contentTitle = "app title";
CharSequence contentText = "text";
Intent notificationIntent = new Intent(this, SuperMicProActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int signed = 1;
mNotificatonManager.notify(signed, notification);
我正在寻找onResume()
可能是某种bringTaskToFront(this)
选择。这存在吗?
谢谢,