對於我的新聞閱讀器應用程序,我製作了一個小部件。使用小部件可以啓動新聞應用程序。但是,如果用戶回到主屏幕,使用後退按鈕,仍然有應用程序的實例。因此,如果用戶進入應用程序列表(所有應用程序)並再次啓動新聞應用程序。新聞應用程序有兩個實例:S要關閉應用程序,用戶需要在後退按鈕上按兩次(因爲您看到的是同一應用程序的兩倍)。我能做些什麼嗎?一次打開主要活動
這裏我的代碼:
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
Intent configIntent = new Intent(context, Main.class);
PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget);
remoteViews.setOnClickPendingIntent(R.id.headlinesBox, configPendingIntent);
// Tell the widget manager
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
}
遺憾的是不工作..:S – Johan