所以我已经看到了很多关于如何从 android 小部件启动活动的解决方案,现在我的问题是,我是否需要在清单中声明一些东西才能启动活动?我有一个带有布局的活动,并且我有带有待处理意图的小部件提供程序,当我单击按钮时会触发它,但它不会带我进入活动。这是我的代码
final int N = appWidgetIds.length;
// Perform this loop procedure for each App Widget that belongs to this provider
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
// Create an Intent to launch ExampleActivity
Intent intent = new Intent(context, WidgetActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
views.setOnClickPendingIntent(R.id.button1, pendingIntent);
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
来自 developer.android 的相同代码,但带有我的按钮 ID 和我的活动名称......