对于我的新闻阅读器应用程序,我制作了一个小部件。使用小部件可以启动新闻应用程序。但是,如果用户回到主屏幕,使用后退按钮,仍然有应用程序的实例。因此,如果用户进入应用程序列表(所有应用程序)并再次启动新闻应用程序。新闻应用程序有两个实例: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