android:软件的安装和卸载源代码

来源:互联网 发布:工业设计学什么软件 编辑:程序博客网 时间:2024/05/01 09:37

安装:从sdcard

  1. String fileName = Environment.getExternalStorageDirectory() + "/myApp.apk";           
  2. Intent intent = new Intent(Intent.ACTION_VIEW);        
  3. intent.setDataAndType(Uri.parse("file://" + filePath),"application/vnd.android.package-archive");        
  4. 或者        
  5. //intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");         
  6. startActivity(intent);    

 

卸载

  1. Uri packageURI = Uri.parse("package:com.android.myapp");           
  2. Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);           
  3. startActivity(uninstallIntent);   

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/fenghome/archive/2010/06/16/5673757.aspx

原创粉丝点击