欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實現(xiàn)用代碼簡單安裝和卸載APK的方法

 更新時間:2016年08月13日 11:51:15   作者:llyofdream  
這篇文章主要介紹了Android實現(xiàn)用代碼簡單安裝和卸載APK的方法,涉及Android針對APK文件及package的相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了Android實現(xiàn)用代碼簡單安裝和卸載APK的方法。分享給大家供大家參考,具體如下:

public class TestInstallAPK extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 // TODO Auto-generated method stub
 super.onCreate(savedInstanceState);
 // this.unInstallFile();
 installFile();
 }
 /**
 * install APK code
 */
 private void installFile(){
 Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setAction(android.content.Intent.ACTION_VIEW);
//  String type = getMIMEType(f);
//  intent.setDataAndType(Uri.fromFile(f), type);
 intent.setDataAndType(Uri.parse("file://" + "/sdcard/Android_gc.apk"),
  "application/vnd.android.package-archive");
 this.startActivity(intent);
 }
 /**
 * uninstall APK code
 */
 private void unInstallFile(){
 Uri uri=Uri.parse("package:com.gameclient");
 Intent intent = new Intent(Intent.ACTION_DELETE,uri);
 this.startActivity(intent);
 }
}

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論