Android requestPinAppWidget在最近安装后返回false
我对AppWidgetManager::requestPinAppWidget有问题 有时方法Android requestPinAppWidget在最近安装后返回false,android,android-widget,samsung-mobile,android-8.0-oreo,Android,Android Widget,Samsung Mobile,Android 8.0 Oreo,我对AppWidgetManager::requestPinAppWidget有问题 有时方法requestPinAppWidget返回false。我们通过卸载应用程序并使用android studio从fresh重新安装来复制它。我们可以使用以下代码在三星和像素设备上始终如一地复制它: @RequiresApi(Build.VERSION_CODES.O) private fun showWidgetAddingActivity(context: Context) { val appW
requestPinAppWidget
返回false。我们通过卸载应用程序并使用android studio从fresh重新安装来复制它。我们可以使用以下代码在三星和像素设备上始终如一地复制它:
@RequiresApi(Build.VERSION_CODES.O)
private fun showWidgetAddingActivity(context: Context) {
val appWidgetManager = context.applicationContext.getSystemService(AppWidgetManager::class.java)
val myProvider = ComponentName(context.applicationContext, WidgetActionsReceiver::class.java)
val launcherSupported = appWidgetManager.requestPinAppWidget(myProvider,null, null)
}
如果我们在新安装后(或之后几分钟内)运行此操作,则launchessupported
的值将为false
。在任何其他情况下,它都是真的
发生这种情况时,调用appWidgetManager.isRequestPinAppWidgetSupported始终返回true
为什么呢?我如何减轻它?或者至少提前知道它,所以我不会向用户显示流的其余部分这是由于默认情况下禁用了
WidgetActionsReceiver
而导致的。当使用功能标志启用时,更改需要一段时间才能到达启动器。您能否详细说明禁用WidgetActionsReceiver
的意思以及您是如何启用它的?