真的不知道如何搜索这个......
每当从我的队列中添加或删除作业以在状态栏中放置通知时,我都会调用以下内容:
private void showNotification()
{
int jobsize = mJobQueue.size();
int icon = (jobsize == 0) ?
android.R.drawable.stat_sys_upload_done :
android.R.drawable.stat_sys_upload;
Notification notification =
new Notification(icon, "Test", System.currentTimeMillis());
Intent intent = new Intent(this, FileManagerActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
notification.flags =
(Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL);
notification.setLatestEventInfo(this,
"Uploading to our servers",
getString((jobsize > 0) ?
R.string.notification_active_transfers :
R.string.notification_no_transfers),
pendingIntent);
mNotifyManager.notify(NOTIFICATION, notification);
}
现在的行为是这样的:
如果用户注销并点击通知,它仍然会打开一个新的 FileManagerActivity (操作!)我可以通过从我的身份验证活动开始并以自然顺序将意图传递到我的堆栈来解决这个问题,当应用程序已经存在时跑步是我遇到困难的地方。
如果用户已经打开 FileManagerActivity,单击通知将在其上放置第二个实例。在这种情况下,我希望当前正在运行的 FileManagerActivity 接收焦点,而不是启动一个新实例。
我怎样才能得到正确的行为?