startService()是否創建一個新的Service實例或使用現有的實例? 例如,在下面的代碼中,它是創建兩個UpdateService實例還是隻創建一個UpdateService實例? 謝謝。startService()是否創建一個新的Service實例或使用現有的實例?
int[] appWidgetIds = new int[] {1, 2};
for (int appWidgetId : appWidgetIds) {
Intent intent = new Intent(context, UpdateService.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
context.startService(intent);
}
謝謝@CommonsWare我upvoted你的問題,每次我看到你的答案,它最容易理解,我發現有幫助和upvote你的答案:) – blackHawk 2017-08-25 09:02:32