requestWindowFeature(Window.FEATURE_NO_TITLE);
String unknown = getString(R.string.unknown);
setContentView(R.layout.op_progress);
//initialize views
PackageUtil.initAppSnippet(this, mAppInfo, R.id.app_snippet);
TextView installTextView = (TextView)findViewById(R.id.center_text);
installTextView.setText(R.string.installing);
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
mProgressBar.setIndeterminate(true);
// Set flag to replace package if already existing
int installFlags = 0;
PackageManager pm = getPackageManager();
try {
PackageInfo pi = pm.getPackageInfo(mAppInfo.packageName,
PackageManager.GET_UNINSTALLED_PACKAGES);
if(pi != null) {
installFlags |= PackageManager.REPLACE_EXISTING_PACKAGE;
}
} catch (NameNotFoundException e) {
}
if((installFlags & PackageManager.REPLACE_EXISTING_PACKAGE )!= 0) {
Log.w(TAG, "Replacing package:"+mAppInfo.packageName);
}
PackageInstallObserver observer = new PackageInstallObserver();
pm.installPackage(mPackageURI, observer, installFlags);