您好,登錄后才能下訂單哦!
Android安裝卸載程序的具體操作方法,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。
對(duì)于編程愛(ài)好者們來(lái)說(shuō),Android手機(jī)操作系統(tǒng)是一款非常實(shí)用的系統(tǒng)。他們可以進(jìn)行各種Android應(yīng)用程序的開(kāi)發(fā)來(lái)滿(mǎn)足自的應(yīng)用需求。在這里我們就先來(lái)為大家講解一下有關(guān)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>
因?yàn)楦鶕?jù)里面的權(quán)限我們可以 安裝一個(gè)程序從sd卡:
String fileName = Environment.getExternalStorageDirectory()
+ "/myApp.apk";Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(fileName)),
"application/vnd.android.package-archive");startActivity(intent);
Android安裝卸載程序的操作中要想卸載一個(gè)程序;
Uri packageURI = Uri.parse("package:com.android.myapp");
Intent uninstallIntent = new Intent
(Intent.ACTION_DELETE, packageURI);startActivity(uninstallIntent);
默認(rèn)是不支持安裝非市場(chǎng)程序的 因此判斷一下
int result = Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0);if (result == 0) {
// show some dialog here
// ...
// and may be show application settings dialog manually
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_SETTINGS);
startActivity(intent);
}
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝您對(duì)億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。