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)容感興趣的讀者可查看本站專題:《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 Handler的postDelayed()關(guān)閉的方法及遇到問(wèn)題
這篇文章主要介紹了Android Handler的postDelayed()關(guān)閉的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-04-04android計(jì)時(shí)器,時(shí)間計(jì)算器的實(shí)現(xiàn)方法
android計(jì)時(shí)器,時(shí)間計(jì)算器的實(shí)現(xiàn)方法,需要的朋友可以參考一下2013-03-03Android繼承現(xiàn)有控件拓展實(shí)現(xiàn)自定義控件textView
這篇文章主要介紹了Android繼承現(xiàn)有控件拓展實(shí)現(xiàn)自定義控件textView的相關(guān)資料,需要的朋友可以參考下2016-04-04Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航
這篇文章主要為大家詳細(xì)介紹了Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航的相關(guān)資料,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05Android實(shí)現(xiàn)ListView異步加載的方法(改進(jìn)版)
這篇文章主要介紹了Android實(shí)現(xiàn)ListView異步加載的方法,針對(duì)前面介紹的方法進(jìn)行了線程操作的改進(jìn),具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-08-08Android 超詳細(xì)講解fitsSystemWindows屬性的使用
fitsSystemWindows屬性可以讓view根據(jù)系統(tǒng)窗口來(lái)調(diào)整自己的布局;簡(jiǎn)單點(diǎn)說(shuō)就是我們?cè)谠O(shè)置應(yīng)用布局時(shí)是否考慮系統(tǒng)窗口布局,這里系統(tǒng)窗口包括系統(tǒng)狀態(tài)欄、導(dǎo)航欄、輸入法等,包括一些手機(jī)系統(tǒng)帶有的底部虛擬按鍵2022-03-03android如何取得本地通訊錄的頭像的原圖的實(shí)現(xiàn)代碼
這篇文章主要介紹了android如何取得本地通訊錄的頭像的原圖的實(shí)現(xiàn)代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-12-12Android中使用Camera類(lèi)編寫(xiě)手機(jī)拍照App的實(shí)例教程
這篇文章主要介紹了Android中使用Camera類(lèi)編寫(xiě)手機(jī)拍照App的實(shí)例教程,整理了Camera調(diào)用硬件進(jìn)行拍照的一些常用方法,需要的朋友可以參考下2016-04-04