从状态栏通知启动webview类

时间:2011-09-02 03:36:41

标签: android

当我点击我的状态栏通知时,它会加载我的webview,但每次都会重新加载它。有没有办法加载保存状态?谢谢,这就是我所拥有的:

    @Override
public void onStart(Intent intent, int startid) {
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    int icon = R.drawable.notification_icon;
    CharSequence tickerText = "Now playing...";
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    Context context = getApplicationContext();
    CharSequence contentTitle = "Music Promotion";
    CharSequence contentText = "Now Playing...";
    Intent notificationIntent = new Intent(this, mainmenu.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);



    mNotificationManager.notify(HELLO_ID, notification);

}

2 个答案:

答案 0 :(得分:0)

添加以下内容:

notificationIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

这是文档对FLAG_ACTIVITY_REORDER_TO_FRONT所说的内容:

  

如果在传递给Context.startActivity()的Intent中设置,则此标志将为   导致已启动的活动被带到其任务的前端   历史堆栈如果已经在运行。

答案 1 :(得分:0)

我将android清单中的启动模式更改为singleInstance,这似乎已经完成了这个技巧