List of usage examples for android.content.pm PackageManager INSTALL_FAILED_INVALID_APK
int INSTALL_FAILED_INVALID_APK
To view the source code for android.content.pm PackageManager INSTALL_FAILED_INVALID_APK.
Click Source Link
From source file:com.android.packageinstaller.PackageInstallerActivity.java
private void processPackageUri(final Uri packageUri) { mPackageURI = packageUri;/* w ww .jav a2 s . c o m*/ final String scheme = packageUri.getScheme(); final PackageUtil.AppSnippet as; switch (scheme) { case SCHEME_PACKAGE: { try { mPkgInfo = mPm.getPackageInfo(packageUri.getSchemeSpecificPart(), PackageManager.GET_PERMISSIONS | PackageManager.GET_UNINSTALLED_PACKAGES); } catch (NameNotFoundException e) { } if (mPkgInfo == null) { Log.w(TAG, "Requested package " + packageUri.getScheme() + " not available. Discontinuing installation"); showDialogInner(DLG_PACKAGE_ERROR); setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK); return; } as = new PackageUtil.AppSnippet(mPm.getApplicationLabel(mPkgInfo.applicationInfo), mPm.getApplicationIcon(mPkgInfo.applicationInfo)); } break; case SCHEME_FILE: { File sourceFile = new File(packageUri.getPath()); PackageParser.Package parsed = PackageUtil.getPackageInfo(sourceFile); // Check for parse errors if (parsed == null) { Log.w(TAG, "Parse error when parsing manifest. Discontinuing installation"); showDialogInner(DLG_PACKAGE_ERROR); setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK); return; } mPkgInfo = PackageParser.generatePackageInfo(parsed, null, PackageManager.GET_PERMISSIONS, 0, 0, null, new PackageUserState()); as = PackageUtil.getAppSnippet(this, mPkgInfo.applicationInfo, sourceFile); } break; case SCHEME_CONTENT: { mStagingAsynTask = new StagingAsyncTask(); mStagingAsynTask.execute(packageUri); return; } default: { Log.w(TAG, "Unsupported scheme " + scheme); setPmResult(PackageManager.INSTALL_FAILED_INVALID_URI); clearCachedApkIfNeededAndFinish(); return; } } PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); initiateInstall(); }