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;
}