学习机记录
卸载app
// Uri packageUri = Uri.parse("package:"+MainActivity.this.getPackageName());
//
// Intent intent = new Intent(Intent.ACTION_DELETE,packageUri);
// startActivity(intent);
跳转桌面
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName componentName = new ComponentName("com.android.launcher3","com.android.launcher3.Launcher");
intent.setComponent(componentName);
startActivity(intent);
/**
* 静默安装
* @param path apk文件全路径
*/
public static void install_app(Context context, String path) {
Intent it = new Intent("com.android.cus_install_app");
it.putExtra("APP_PATH", path);
it.addFlags(0x01000000);
context.sendBroadcast(it);
}
public static void uninstall_app(Context context, String packageName) {
Intent it = new Intent("com.android.cus_uninstall_app");
it.putExtra("APP_PACKAGNAME", packageName);
it.addFlags(0x01000000);
context.sendBroadcast(it);
}