我有一个要实现的功能:以编程方式安装apk。我正在使用的代码:在Android M开发人员预览中找不到PackageInstallerActivity
ComponentName comp = new ComponentName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");
Intent newIntent = new Intent(callingIntent);
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
newIntent.setComponent(comp);
callingIntent包含来自另一个服务的apk。
在Android 6.0(MPA44G,Nexus 5)上,这个意图崩溃了。 Logcat:
08-20 14:58:56.127 26222 26222 E AndroidRuntime: Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.packageinstaller/com.android.packageinstaller.PackageInstallerActivity}; have you declared this activity in your AndroidManifest.xml?
在棒棒糖设备上,上面的代码工作正常。
Google是否完全删除了PackageInstallerActivity?是否有任何解决方法在Android 6.0上专门以编程方式安装apk?
我使用的Nexus 5采用Android M和您的解决方案是给我:'ActivityNotFoundException' – pkuszewski