溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

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

發布時間:2021-11-11 15:57:19 來源:億速云 閱讀:248 作者:柒染 欄目:移動開發

Android安裝卸載程序的具體操作方法,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有這方面需求的人可以來學習下,希望你能有所收獲。

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

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

< activity android:name=".PackageInstallerActivity">   < intent-filter>   < action android:name="android.intent.action.VIEW" />   < category android:name="android.intent.category.DEFAULT" />   < data android:scheme="content" />   < data android:scheme="file" />   < data android:mimeType="application/vnd.android.package-archive" />   < /intent-filter>   < /activity>   < activity android:name=".UninstallerActivity">   < intent-filter>   < action android:name="android.intent.action.VIEW" />   < action android:name="android.intent.action.DELETE" />   < category android:name="android.intent.category.DEFAULT" />   < data android:scheme="package" />   < /intent-filter>   < /activity>

因為根據里面的權限我們可以 安裝一個程序從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);   

看完上述內容是否對您有幫助呢?如果還想對相關知識有進一步的了解或閱讀更多相關文章,請關注億速云行業資訊頻道,感謝您對億速云的支持。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女