我有一個要實現的功能:以編程方式安裝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