Android實(shí)現(xiàn)用代碼簡(jiǎn)單安裝和卸載APK的方法
本文實(shí)例講述了Android實(shí)現(xiàn)用代碼簡(jiǎ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)容感興趣的讀者可查看本站專(zhuān)題:《Android開(kāi)發(fā)入門(mén)與進(jìn)階教程》、《Android調(diào)試技巧與常見(jiàn)問(wèn)題解決方法匯總》、《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
相關(guān)文章
Android通過(guò)RemoteViews實(shí)現(xiàn)跨進(jìn)程更新UI示例
本篇文章主要介紹了Android通過(guò)RemoteViews實(shí)現(xiàn)跨進(jìn)程更新UI示例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02
android獲取相冊(cè)圖片和路徑的實(shí)現(xiàn)方法
這篇文章主要介紹了android獲取相冊(cè)圖片和路徑的實(shí)現(xiàn)方法,本文介紹的是Android4.4后的方法,感興趣的小伙伴們可以參考一下2016-04-04
Android實(shí)現(xiàn)為T(mén)ab添加Menu的方法
這篇文章主要介紹了Android實(shí)現(xiàn)為T(mén)ab添加Menu的方法,分析了兩種解決方法的思路并對(duì)比分析了相應(yīng)的優(yōu)缺點(diǎn),具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-10-10
Android提高之TelephonyManager功能探秘
這篇文章主要介紹了Android的TelephonyManager功能,可以幫助讀者更好的理解Java反射機(jī)制,需要的朋友可以參考下2014-08-08
為Retrofit統(tǒng)一添加post請(qǐng)求的默認(rèn)參數(shù)的方法
這篇文章主要介紹了為Retrofit統(tǒng)一添加post請(qǐng)求的默認(rèn)參數(shù)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-04-04
Android開(kāi)發(fā)之保存圖片到相冊(cè)的三種方法詳解
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)的保存圖片到相冊(cè)功能的三種方法,文中的示例代碼講解詳細(xì),有一定的參考價(jià)值,感興趣的可以了解一下2022-04-04
android 調(diào)用JNI SO動(dòng)態(tài)庫(kù)的方法
android 調(diào)用JNI 分為靜態(tài)調(diào)用與動(dòng)態(tài)調(diào)用,接下來(lái)通過(guò)本文給大家介紹android 調(diào)用JNI SO動(dòng)態(tài)庫(kù)的方法,感興趣的朋友一起看看吧2021-11-11
Android中實(shí)現(xiàn)GPS定位的簡(jiǎn)單例子
這篇文章主要介紹了Android中實(shí)現(xiàn)GPS定位的簡(jiǎn)單例子,例子邏輯清晰,但相對(duì)簡(jiǎn)單了些,需要的朋友可以參考下2014-07-07

