在我的 AppsServe 中,我加载已安装的软件包:
mApps = mContext.getPackageManager().queryIntentActivities(mainIntent, 0);
然后我显示应用程序的图标和标签。我想在点击图标或标签后开始活动。
我在 onUpdate 的 WidgetProvider 中设置了一个 pendingIntentTemplate:
Intent appsIntent = new Intent(context, AppsService.class);
String packageName = appsIntent.getStringExtra(APP_ID);
appsIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
PendingIntent appsPendingIntent = PendingIntent.getActivity(context, 0, appsIntent, PendingIntent.FLAG_UPDATE_CURRENT);
views.setPendingIntentTemplate(R.id.GridViewApps, appsPendingIntent);
在 AppsService 中,我声明了 setOnClickFillInIntent:
Intent fillInIntent = new Intent();
fillInIntent.setPackage(packageName);
Bundle extras = new Bundle();
fillInIntent.putExtras(extras);
fillInIntent.addCategory(Intent.CATEGORY_DEFAULT);
rv.setOnClickFillInIntent(R.id.app_thumb, fillInIntent);
rv.setOnClickFillInIntent(R.id.app_name, fillInIntent);
但是当我点击图标或标签时,它什么也不做。
LogCat 在任何点击时都会显示以下内容:
07-24 11:51:06.153: E/DatabaseUtils(16583): Writing exception to parcel
07-24 11:51:06.153: E/DatabaseUtils(16583): java.lang.SecurityException: Permission Denial: get/set setting for user asks to run as user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
07-24 11:51:06.153: E/DatabaseUtils(16583): at com.android.server.am.ActivityManagerService.handleIncomingUser(ActivityManagerService.java:14643)
07-24 11:51:06.153: E/DatabaseUtils(16583): at android.app.ActivityManager.handleIncomingUser(ActivityManager.java:2469)
07-24 11:51:06.153: E/DatabaseUtils(16583): at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:688)
07-24 11:51:06.153: E/DatabaseUtils(16583): at android.content.ContentProvider$Transport.call(ContentProvider.java:325)
07-24 11:51:06.153: E/DatabaseUtils(16583): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:275)
07-24 11:51:06.153: E/DatabaseUtils(16583): at android.os.Binder.execTransact(Binder.java:404)
07-24 11:51:06.153: E/DatabaseUtils(16583): at dalvik.system.NativeStart.run(Native Method)
07-24 11:51:06.384: W/ActivityManager(16583): destPackageName = null