自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Android安裝卸載程序具體操作方法解析

移動開發(fā) Android
Android安裝卸載程序在實際應(yīng)用中是一個比較基本的操作。作為初學者來說需要牢固掌握這一應(yīng)用技巧,以方便我們的使用。

對于編程愛好者們來說,Android手機操作系統(tǒng)是一款非常實用的系統(tǒng)。他們可以進行各種Android應(yīng)用程序的開發(fā)來滿足自的應(yīng)用需求。在這里我們就先來為大家講解一下有關(guān)Android安裝卸載程序的具體操作步驟。

在Android安裝卸載程序的源碼中我們知道:

  1. < activity android:name=".PackageInstallerActivity">   
  2. < intent-filter>   
  3. < action android:name="android.intent.action.VIEW" />   
  4. < category android:name="android.intent.category.DEFAULT" />   
  5. < data android:scheme="content" />   
  6. < data android:scheme="file" />   
  7. < data android:mimeType="application/vnd.android.package-archive" />   
  8. < /intent-filter>   
  9. < /activity>   
  10. < activity android:name=".UninstallerActivity">   
  11. < intent-filter>   
  12. < action android:name="android.intent.action.VIEW" />   
  13. < action android:name="android.intent.action.DELETE" />   
  14. < category android:name="android.intent.category.DEFAULT" />   
  15. < data android:scheme="package" />   
  16. < /intent-filter>   
  17. < /activity> 

因為根據(jù)里面的權(quán)限我們可以 安裝一個程序從sd卡:

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

Android安裝卸載程序的操作中要想卸載一個程序;

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

默認是不支持安裝非市場程序的 因此判斷一下

  1. int result = Settings.Secure.getInt(getContentResolver(),
     Settings.Secure.INSTALL_NON_MARKET_APPS, 0);   
  2. if (result == 0) {   
  3. // show some dialog here   
  4. // ...   
  5. // and may be show application settings dialog manually   
  6. Intent intent = new Intent();   
  7. intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);   
  8. startActivity(intent);   

Android安裝卸載程序的具體實現(xiàn)方法就為大家介紹到這里。

【編輯推薦】

  1. Android Jni代碼示例講解 
  2. Android單元測試源碼解讀 
  3. Android判斷網(wǎng)絡(luò)狀態(tài)方法詳解 
  4. Android程序架構(gòu)基本內(nèi)容概述 
  5. Android調(diào)用平臺功能具體技巧分享 
責任編輯:曹凱 來源: javaeye.com
相關(guān)推薦

2009-12-30 16:48:52

Silverlight

2010-02-02 13:57:31

C++解析#pragm

2010-01-27 18:00:57

Android開機自啟

2010-04-02 08:42:32

Oracle 游標

2010-02-03 13:26:53

C++計時

2010-02-02 17:13:35

C++ Endian

2010-01-07 15:37:35

VB.NET ForNext循環(huán)

2010-04-13 17:00:27

Oracle NLS_

2010-03-05 15:27:06

Python文件路徑

2010-02-02 16:23:46

C++實現(xiàn)WPF動畫

2010-03-19 14:19:58

Python正則表達式

2010-03-05 17:06:26

Python顯示UTF

2009-12-10 13:35:25

Linux操作系統(tǒng)

2009-12-30 15:47:40

Silverlight

2011-03-17 09:06:58

iptables映射端口

2009-09-10 14:49:00

2009-08-31 13:32:38

C#創(chuàng)建XML文件

2010-01-05 16:02:36

Ubuntu Git

2010-05-14 14:46:38

MySQL手動安裝

2010-08-02 17:20:12

nfs啟動Linux
點贊
收藏

51CTO技術(shù)棧公眾號