Methods Summary |
---|
private void | deletePackage()
final int curSelection = getSelectedItemPosition();
if (curSelection >= 0) {
// todo: verification dialog for package deletion
final PackageInfo packageInfo = mAdapter.itemForPosition(curSelection);
if (packageInfo != null) {
getPackageManager().deletePackage(packageInfo.packageName,
new IPackageDeleteObserver.Stub() {
public void packageDeleted(boolean succeeded) throws RemoteException {
if (succeeded) {
mPackageInfoList.remove(curSelection);
mHandler.post(new Runnable() {
public void run() {
mAdapter.notifyDataSetChanged();
}
});
// todo: verification dialog for data directory
final String dataPath = packageInfo.applicationInfo.dataDir;
// todo: delete the data directory
} else {
mHandler.post(new Runnable() {
public void run() {
new AlertDialog.Builder(PackageBrowser.this)
.setTitle("Oops")
.setMessage("Could not delete package." +
" Maybe it is in /system/app rather than /data/app?")
.show();
}
});
}
}
},
0);
}
}
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
setupAdapter();
mHandler= new Handler();
registerIntentReceivers();
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
menu.add(0, 0, 0, "Delete package").setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
deletePackage();
return true;
}
});
return true;
|
protected void | onListItemClick(android.widget.ListView l, android.view.View v, int position, long id)
PackageInfo info =
mAdapter.itemForPosition(position);
if (info != null) {
Intent intent = new Intent(
null, Uri.fromParts("package", info.packageName, null));
intent.setClass(this, PackageSummary.class);
startActivity(intent);
}
|
private void | registerIntentReceivers()
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
registerReceiver(new ApplicationsIntentReceiver(), filter);
|
private void | setupAdapter()
mAdapter = new PackageListAdapter(this);
setListAdapter(mAdapter);
|