1

如何从通知中恢复 Android 应用程序?我希望能够使用所有有界服务和设置等从它离开的地方恢复实例。而不是一个完整的新实例。这是我的代码:

String ns = Context.NOTIFICATION_SERVICE;
        mNotificationManager = (NotificationManager)
                                                    getSystemService(ns);

        Intent notificationIntent = new Intent(this, MeasurementsStarter.class);
        PendingIntent contentIntent = PendingIntent.getActivity(
                                                    this, 0, notificationIntent, 0);
        // the next two lines initialize the Notification, using the configurations
        // above
        notification = new Notification(R.drawable.ic_launcher, "Metingen draaien",System.currentTimeMillis());
        notification.setLatestEventInfo(getBaseContext(), "Metingen ManDown", "Metingen Mandown draaien nog",
                                                                    contentIntent);
        notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;   
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        final int HELLO_ID = 1;
        mNotificationManager.notify(HELLO_ID, notification);
4

1 回答 1

0

我找到了一个答案,我手动设置了所有文本字段等中的数据,然后将我的 bindService 放在我的 onCreate() 方法中。这可能不是最优雅的方式,但它仍然有效

于 2013-10-25T06:30:09.420 回答