小部件固定不使用Android华为和体内设备

发布于 2025-02-04 18:52:46 字数 1331 浏览 5 评论 0 原文

我开发 可以将小部件固定在主屏幕上,它在大多数设备上都可以很好地工作,但与华为和Vivo手机无法使用。

当我通过调用 appWidgetManager.requestpinappwidget()来调用 appwidgetManager.requestpinappwidget()时,它将调用 android:configure 代码> AppWidget-Provider 。确认配置后,设置将得到正确保存,但是华为/Vivo Launcher显示错误并且不会加载小部件(并且错误与我的应用无关!)。

我还尝试创建另一个 appwidget-provider 没有 Android:configure 参数,并且它在华为手机上完美工作(但不能在Vivo上工作!)。但是,Android将在启动器的小部件选择屏幕(即小部件拾音器)上显示另一个小部件。如果我使用 android:widgetFeatures = hide_from_picker 它只能从Android API 28+起作用,并且旧设备仍然会看到一个无法配置的“错误”窗口小部件选项(注意:Huawei Phones huawei huawei dimploye dimploy nimploy dimploy nimploy dimploye huawei himo选项,即使它们是API 28+)。

无论如何,我可以修复小部件固定在华为手机,体内手机或行为行为的设备上?

更新:目前,我决定禁用 build.manfucturer.tolowercase()“ vivo” “ huawei” “ vivo” 是“ vivo” 。

更新2:我用 AppWidgetManager.RequestPinappWidget()也与华为和Vivo设备一起使用,因此是他们的默认启动器,它是错误的... :(

I developed an app that can pin widgets to the home screen, it works perfectly on most devices, but not with Huawei and Vivo phones.

When I pin a widget with a Huawei/Vivo device by calling appWidgetManager.requestPinAppWidget() then it will invoke the configuration screen as defined in the android:configure field of the appwidget-provider. Once I confirm the configuration, settings are saved properly, but Huawei/Vivo launcher shows an error and does not load the widget (and the error is not related to my app!).

I also tried to create another appwidget-provider without the android:configure parameter, and it works perfectly on Huawei phones (but not working on Vivo!). However, Android will show another widget on the launcher’s widget selection screen (i.e. the widget picker). If I use android:widgetFeatures=hide_from_picker it will work only from Android API 28+, and older devices will still see a “wrong” widget option that cannot be configured (note: Huawei phones will simply ignore that options, even if they are API 28+).

Any way I can fix the widget pinning on Huawei phones, Vivo phones, or devices that behave like that?

UPDATE: at present I decided to disable the widget pinning feature when Build.MANUFACTURER.toLowerCase() is either "vivo" or "huawei".

UPDATE 2: I tested with Nova Launcher, and appWidgetManager.requestPinAppWidget() works perfectly also with Huawei and Vivo devices, thus it is their default Launcher which is buggy... :(

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

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

发布评论

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

评论(1

愿得七秒忆 2025-02-11 18:52:46

这不是问题的解决方案,但是我最终禁用 appwidgetManager.requestpinappwidget()使用Vivo和Huawei默认启动器的设备功能以下方式:

  1. 添加到您的清单:
 < Queries>
     < intent>
         < Action Android:name =“ android.intent.action.main” />
         <类别Android:name =“ android.intent.category.home” />
     </intent>
 </queries>
 
  1. 使用此方法检测当前默认启动器是否支持窗口小部件固定:

     私有静态布尔值isusingsupportedLauncher(上下文上下文){
    
         packagemanager packageManager = context.getPackageManager();
         意图意图= new Intent(Intent.Action_Main);
         intent.addcategory(intent.category_home);
         字符串pname = packagemanager.resolVeactivity(intent,packagemanager.match_default_only).activityInfo.packageName;
    
         //华为发射器不支持小部件固定
         if(textutils.equals(pname,“ com.huawei.android.launcher”))))))
            返回false;
    
         // Vivo和Nokia-Go Launcher不支持小部件固定
         if(textutils.equals(pname,“ com.android.launcher3”))
            返回false;
    
         返回true;
    
       }
     

注意:使用第三方发射器的更多技术精通的用户仍然可以在Huawei和Vivo设备上享受窗口小部件的功能,其余的将不得不添加发射器本身的小部件...

This is not the fix to the issue, but I ended up disabling appWidgetManager.requestPinAppWidget() functionality for devices using Vivo and Huawei default launchers in the following way:

  1. Add to your manifest:
 <queries>
     <intent>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.HOME" />
     </intent>
 </queries>
  1. Use this method to detect if the current default launcher supports or not widget pinning:

       private static boolean isUsingSupportedLauncher(Context context) {
    
         PackageManager packageManager = context.getPackageManager();
         Intent intent = new Intent(Intent.ACTION_MAIN);
         intent.addCategory(Intent.CATEGORY_HOME);
         String pname = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY).activityInfo.packageName;
    
         // Huawei launcher is not supported for widget pinning
         if (TextUtils.equals(pname, "com.huawei.android.launcher"))
            return false;
    
         // Vivo and Nokia-Go launcher is not supported for widget pinning
         if (TextUtils.equals(pname, "com.android.launcher3"))
            return false;
    
         return true;
    
       }
    

Note: more tech-savvy users that use a third-party launcher can still enjoy the widget-pinning feature on Huawei and Vivo devices, the rest will have to add widget(s) from the launcher itself...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文