uninstall apk
- Uri uninstallUri = Uri.fromParts("package", "xxx", null);
- returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);
install apk
- Uri installUri = Uri.fromParts("package", "xxx", null);
- returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);
play audio
- Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");
- returnIt = new Intent(Intent.ACTION_VIEW, playUri);
- //发送附件
- Intent it = new Intent(Intent.ACTION_SEND);
- it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
- it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");
- sendIntent.setType("audio/mp3");
- startActivity(Intent.createChooser(it, "Choose Email Client"));
- //搜索应用
- Uri uri = Uri.parse("market://search?q=pname:pkg_name");
- Intent it = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(it);
- //where pkg_name is the full package path for an application
- //显示指定应用的详细页面(这个好像不支持了,找不到app_id)
- Uri uri = Uri.parse("market://details?id=app_id");
- Intent it = new Intent(Intent.ACTION_VIEW, uri);
- startActivity(it);
- //where app_id is the application ID, find the ID
- //by clicking on your application on Market home
- //page, and notice the ID from the address bar
/**
* 获得包安装Intent
* @param tempFile
* @return
*/
public static Intent getPackageInstallIntent(File tempFile)
{
Uri mPackageURI = Uri.fromFile(tempFile);
Intent in = new Intent();
in.setAction(Intent.ACTION_VIEW);
in.addCategory(Intent.CATEGORY_DEFAULT);
in
.setComponent(new ComponentName(
"com.android.packageinstaller",
"com.android.packageinstaller.PackageInstallerActivity"));
in.setDataAndType(mPackageURI,
"application/vnd.android.package-archive");
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return in;
}
* 获得包安装Intent
* @param tempFile
* @return
*/
public static Intent getPackageInstallIntent(File tempFile)
{
Uri mPackageURI = Uri.fromFile(tempFile);
Intent in = new Intent();
in.setAction(Intent.ACTION_VIEW);
in.addCategory(Intent.CATEGORY_DEFAULT);
in
.setComponent(new ComponentName(
"com.android.packageinstaller",
"com.android.packageinstaller.PackageInstallerActivity"));
in.setDataAndType(mPackageURI,
"application/vnd.android.package-archive");
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return in;
}