查InstallAppProgress源码发现有个EXTRA_RETURN_RESULT
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case INSTALL_COMPLETE:
if (getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false)) {
Intent result = new Intent();
result.putExtra(Intent.EXTRA_INSTALL_RESULT, msg.arg1);
setResult(msg.arg1 == PackageInstaller.STATUS_SUCCESS
? Activity.RESULT_OK : Activity.RESULT_FIRST_USER,
result);
clearCachedApkIfNeededAndFinish();
return;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_RETURN_RESULT,true);
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
try {
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException ex) {
return false;
}