首页 > 其他 > 详细

apk安装与卸载

时间:2015-04-07 09:36:04      阅读:270      评论:0      收藏:0      [点我收藏+]
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); 
    }

 

apk安装与卸载

原文:http://www.cnblogs.com/guduey/p/4397432.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!