在华为设备上设置默认Android启动器? [英] Set Default Android Launcher on Huawei devices?

查看:1666
本文介绍了在华为设备上设置默认Android启动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是将我的应用设置为华为设备上的默认启动器.

My Goal is here is to set my app as default launcher on Huawei devices.

1-说明:

1.1-当前情况:

我已经能够:

  • 检查我的应用是否为默认启动器
  • 显示启动器选择器"(具有使用一次"/始终"选择)

一切正常.. 在华为设备上除外!

This all works fine.. except on Huawei devices!

从我的角度来看,华为的Android风格无法正确地荣誉""ACTION_MANAGE_DEFAULT_APPS_SETTINGS"意图行动合同.

From my point of view, Huawei's Android flavor does not properly 'honor' the "ACTION_MANAGE_DEFAULT_APPS_SETTINGS" intent action contract.

// this displays the list of default apps on all tested devices, except on Huawei devices!
// instead, it does display apps permissions, app links and apps'advanced settings
intent.setAction(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
activity.startActivity(intent);

作为B计划,我可以显示应用程序和通知的设置页面"使用以下方法:

As a B Plan, I am able to display the 'Applications & Notifications' settings 'page' using this:

String packageName = "com.android.settings";
String className = "Settings$AppAndNotificationDashboardActivity";
intent.setClassName(packageName, packageName + "." + className);
activity.startActivity(intent);

因此用户可以从此处导航,按以下菜单项序列:

So the user can navigate from there, pressing this sequence of menu items:

  • ->高级参数(可扩展菜单项:在平板电脑上不存在,并且不确定在手机上是否存在)
  • ->默认应用
  • ->默认启动器

这需要2到3步,我想避免.

1.2-可以改进!

我发现,当"- >默认应用程序"菜单项中选择了的(com.android.settings,.SubSettings)的意向(额外)推出,但我没能使它起作用(拒绝权限).

I found out that when the "-> Default Apps" menu item is selected, a (com.android.settings, .SubSettings) Intent (with extra) is launched but I was not able to make this works (permission denial).

但是我安装了 Nova Launcher 事实证明,它可以在华为设备上显示->默认应用"设置页面!
因此,用户登陆到仅需点击->默认启动器"然后选择默认启动器的页面:轻松得多.

But I installed Nova Launcher and it turns out it's able to display the "-> Default Apps" settings page on Huawei devices!
So the user land on a page where she/he only has to tap on "-> Default Launcher" then choose a default launcher: much easier.

2-问题:

我认为不可能在华为设备上显示"Lancher Picker",这是我的问题:
如何在华为设备上显示->默认应用"设置页面(如下图所示)(如Nova Launcher一样)?
他们在华为设备上使用其他意图动作吗?

As I think it's just not possible to display the 'Lancher Picker' on Huawei devices, here is my question:
How can I display the "-> Default Apps" settings page (image down here) on Huawei devices (like Nova Launcher does)?
Are they using another intent action on Huawei devices?

预先感谢您的帮助.

推荐答案

在华为设备上,Nova使用不同的意图打开正确的屏幕.我可能是通过使用从华为设备拉出的Settings.apk上的apktool并查看了AndroidManifest来找到的. 请注意,"com.android"始终是代码异味,因为这意味着它不是公共API的一部分.同样,它甚至不是真正的"com.android",因为它在AOSP中不存在,并且com.android.settings.PREFERRED_SETTINGS纯粹是华为的发明.某些华为设备很可能根本没有此功能.将来,这种意图还可能会继续起作用,但不能达到目前的目的.所以请小心处理.

Yes on Huawei devices, Nova uses a different intent to open to the correct screen. I likely found this by using apktool on the Settings.apk pulled from a Huawei device and looking at the AndroidManifest. Note that "com.android" is always a code smell as it means it's not part of the public API. Also this isn't even really "com.android" as it doesn't exist on AOSP and com.android.settings.PREFERRED_SETTINGS is purely a Huawei invention. It's very likely that some Huawei devices won't have this at all. It's also possible that in the future this intent might continue to work but not do what it currently does. So handle it carefully.

/* Some Huawei devices don't let us reset normally, handle it by opening preferred apps */
Intent preferredApps = new Intent("com.android.settings.PREFERRED_SETTINGS");
preferredApps.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
if (pm.resolveActivity(preferredApps, 0) != null) {
    context.startActivity(preferredApps);
} else {
    ...
}

这篇关于在华为设备上设置默认Android启动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆