apk安装与卸载

public void installApk() {
        /*
         * <action android:name="android.intent.action.VIEW" /> <action
         * android:name="android.intent.action.INSTALL_PACKAGE" /> <category
         * android:name="android.intent.category.DEFAULT" /> <data
         * android:scheme="file" /> <data
         * android:mimeType="application/vnd.android.package-archive" />
         */
        String fileName = Environment.getExternalStorageDirectory()
                + "/myApp.apk";
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(fileName)),
                "application/vnd.android.package-archive");
        startActivity(intent);
    }
    
    public void uninstallApk() {
        /*
        <intent-filter>  
        <action android:name="android.intent.action.DELETE" />  
        <action android:name="android.intent.action.UNINSTALL_PACKAGE" />  
        <category android:name="android.intent.category.DEFAULT" />  
        <data android:scheme="package" />  
         */
        Uri packageURI = Uri.parse("package:com.android.myapp");     
        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);     
        startActivity(uninstallIntent); 
    }
原文地址:https://www.cnblogs.com/guduey/p/4397432.html