关于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")可以打开桌面的目录栏,选择第二个华为桌面可以跳转至桌面
但是加上.withAbilityName("com.huawei.android.launcher.unihome.UniHomeLauncher")就不可以(这个ability是上一步中hilog中查找到的),报错提示如下,这是权限不够导致的问题吗,
鸿蒙
Intent
HarmonyOS
赞
收藏 0
回答 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);