如何在定制的Android主屏幕中添加默认Widget?

发布于 2024-12-07 11:05:34 字数 2806 浏览 0 评论 0原文

我使用Launcher2主屏幕作为定制主屏幕的基础。 我想使用默认的小部件自定义 Android 主屏幕。

但是当我使用这个示例时,我收到此错误:

09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187): Problem allocating appWidgetId
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187): java.lang.SecurityException: bindGagetId appWidgetId=68 provider=ComponentInfo{com.android.protips/com.android.protips.ProtipWidget}: User 10081 does not have android.permission.BIND_APPWIDGET.
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.os.Parcel.readException(Parcel.java:1322)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.os.Parcel.readException(Parcel.java:1276)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.bindAppWidgetId(IAppWidgetService.java:470)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.appwidget.AppWidgetManager.bindAppWidgetId(AppWidgetManager.java:337)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.addAppWidget(LauncherProvider.java:812)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.addAppWidget(LauncherProvider.java:790)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.loadFavorites(LauncherProvider.java:670)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.onCreate(LauncherProvider.java:239)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider.query(LauncherProvider.java:108)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.content.ContentProvider$Transport.query(ContentProvider.java:187)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.content.ContentResolver.query(ContentResolver.java:271)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.loadWorkspace(LauncherModel.java:711)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.loadAndBindWorkspace(LauncherModel.java:521)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.run(LauncherModel.java:588)

我已经在清单中添加了 android.permission.BIND_APPWIDGET,但它仍然无法正常工作,并且我的默认小部件仍然丢失。

有谁知道可能是什么问题吗?

I use Launcher2 home screen as the basis for customised the home screen.
I wanted to customized Android Home Screen with default Widget.

But when I use this example, I get this error:

09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187): Problem allocating appWidgetId
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187): java.lang.SecurityException: bindGagetId appWidgetId=68 provider=ComponentInfo{com.android.protips/com.android.protips.ProtipWidget}: User 10081 does not have android.permission.BIND_APPWIDGET.
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.os.Parcel.readException(Parcel.java:1322)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.os.Parcel.readException(Parcel.java:1276)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.bindAppWidgetId(IAppWidgetService.java:470)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.appwidget.AppWidgetManager.bindAppWidgetId(AppWidgetManager.java:337)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.addAppWidget(LauncherProvider.java:812)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.addAppWidget(LauncherProvider.java:790)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.loadFavorites(LauncherProvider.java:670)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider$DatabaseHelper.onCreate(LauncherProvider.java:239)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:126)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherProvider.query(LauncherProvider.java:108)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.content.ContentProvider$Transport.query(ContentProvider.java:187)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at android.content.ContentResolver.query(ContentResolver.java:271)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.loadWorkspace(LauncherModel.java:711)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.loadAndBindWorkspace(LauncherModel.java:521)
09-28 12:03:13.052: ERROR/Launcher.LauncherProvider(9187):     at com.android.launcher2.LauncherModel$Loader$LoaderThread.run(LauncherModel.java:588)

I've already added android.permission.BIND_APPWIDGET in my manifest, but it's still not working and my default widget is still missing.

Does anyone have any idea what could be the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东京女 2024-12-14 11:05:34

android.permission.BIND_APPWIDGET 不适用于系统存储之外的应用程序。

如果没有完整的堆栈跟踪,我无法查明错误的确切位置,但这正是我预期导致问题的原因。

void addAppWidget(Intent data) {
        int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
        AppWidgetProviderInfo appWidget = mAppWidgetManager.getAppWidgetInfo(appWidgetId);

        if (appWidget.configure != null) {
            // Launch over to configure widget, if needed
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
            intent.setComponent(appWidget.configure);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

            startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
        } else {
            // Otherwise just add it
            onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
        }
}

android.permission.BIND_APPWIDGET is not available for applications outside of system storage.

Without a full stack trace I cannot pinpoint the exact location of the error but this is what I expect is causing the problem.

void addAppWidget(Intent data) {
        int appWidgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
        AppWidgetProviderInfo appWidget = mAppWidgetManager.getAppWidgetInfo(appWidgetId);

        if (appWidget.configure != null) {
            // Launch over to configure widget, if needed
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
            intent.setComponent(appWidget.configure);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

            startActivityForResultSafely(intent, REQUEST_CREATE_APPWIDGET);
        } else {
            // Otherwise just add it
            onActivityResult(REQUEST_CREATE_APPWIDGET, Activity.RESULT_OK, data);
        }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文