Reg*_*_AG 10 android widget android-intent android-activity
重现问题的步骤:
你知道如何避免这个问题吗?(我在stackoverflow上看到了一些类似的问题但不是我想要的严格意义)
谢谢 !!!!
代码:
public class MyWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// Build the intent to call the service//
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
Intent openAppIntent = new Intent(context.getApplicationContext(), MainActivity.class);
openAppIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
PendingIntent openAppPendingIntent = PendingIntent.getActivity(context, 0, openAppIntent, 0);
remoteViews.setOnClickPendingIntent(R.id.widgetLinearLayout, openAppPendingIntent);
//// ETC…///
}
Run Code Online (Sandbox Code Playgroud)
尝试使用:
openAppIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Run Code Online (Sandbox Code Playgroud)
您还可以使用:
openAppIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5965 次 |
| 最近记录: |