关于Intent跳转桌面问题

使用如下代码进行跳转桌面,不能够跳转

Intent intent_background = new Intent();
Operation operation = new Intent.OperationBuilder()
        .withAction(Intent.ACTION_HOME)
        .withFlags(Intent.FLAG_ABILITY_NEW_MISSION)
        .withBundleName("com.huawei.android.launcher")
        .withAbilityName("com.huawei.android.launcher.unihome.UniHomeLauncher")
        .build();
intent_background.setOperation(operation);
startAbility(intent_background, 1);

单独使用.withBundleName("com.huawei.android.launcher")可以打开桌面的目录栏,选择第二个华为桌面可以跳转至桌面

关于Intent跳转桌面问题-鸿蒙开发者社区但是加上.withAbilityName("com.huawei.android.launcher.unihome.UniHomeLauncher")就不可以(这个ability是上一步中hilog中查找到的),报错提示如下,这是权限不够导致的问题吗,

关于Intent跳转桌面问题-鸿蒙开发者社区

鸿蒙
Intent
HarmonyOS
2021-12-02 09:21:55
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Joshun
1

可以将flag设置为Intent.FLAG_NOT_OHOS_COMPONENT,参考如下:

Intent intent = new Intent();

Operation operation = new Intent.OperationBuilder()

.withAction(Intent.ACTION_HOME)

.withFlags(Intent.FLAG_NOT_OHOS_COMPONENT)

.withBundleName("com.huawei.android.launcher")

.withAbilityName("com.huawei.android.launcher.unihome.UniHomeLauncher")

.build();

intent.setOperation(operation);

startAbility(intent);

分享
微博
QQ
微信
回复
2021-12-02 13:37:02
提问
该提问已有0人参与 ,帮助了0人