Android 如何保持IntentService';什么是持久性?

Android 如何保持IntentService';什么是持久性?,android,android-alarms,intentservice,Android,Android Alarms,Intentservice,我正在构建一个应用程序,其中使用AlarmManager定期运行IntentService: AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent serviceIntent=new Intent(NewsListActivity.this, LatestNewsRetrService.class); PendingIntent pendingServi

我正在构建一个应用程序,其中使用AlarmManager定期运行IntentService:

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
        Intent serviceIntent=new Intent(NewsListActivity.this, LatestNewsRetrService.class);
        PendingIntent pendingService=PendingIntent.getService(getApplicationContext(), 0, serviceIntent, 
                PendingIntent.FLAG_CANCEL_CURRENT);
        alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), REFRESH_INTERVAL, pendingService);
正如大家所知,最新的NewsRetrService类在每次服务运行时都会被创建和销毁;好吧,我的问题是,我想保留这个服务类属性中使用的两个对象,但这是不可能的,因为每次都会重新创建它们。 我甚至尝试将这些对象作为额外对象放入服务意图中,但它们不会更新。 那么,最佳实践是什么?我应该将这些对象保存为主活动的属性吗?对我来说最好的办法是什么

那么,最佳实践是什么

将它们存储在一个文件中