1

我正在使用 DevicePolicyManager 的 addPersistentPreferredActivity() 方法,但它不起作用。

我使用 dpm 命令将 Google Nexus 5.0 android 设备设置为设备所有者,之后我使用上述方法将我的应用程序的活动设置为 HomeActivity,但它不起作用。

下面是我正在使用的一段代码:

IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
filter.addCategory(Intent.CATEGORY_HOME);
filter.addCategory(Intent.CATEGORY_DEFAULT);
devicePolicyManager.addPersistentPreferredActivity(demoDeviceAdmin,filter,new ComponentName(getApplicationContext(),LauncherActivity.class));

谁能帮我解决这个问题?

4

1 回答 1

0

也许你忘了在你的活动清单中添加这个:

<intent-filter>
     <category android:name="android.intent.category.HOME" />
     <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
于 2020-12-09T08:28:39.520 回答