码迷,mamicode.com
首页 > 其他好文 > 详细

apk安装与卸载

时间:2015-04-07 09:37:22      阅读:113      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!