2016-07-15 74 views

回答

2

您可以執行從你的應用程序中adb commands如果你有這樣的

Process process = Runtime.getRuntime().exec("your command"); 
BufferedReader bufferedReader = new BufferedReader(
            new InputStreamReader(process.getInputStream())); 

使用try catchroot訪問,以及該代碼

+0

我應該用什麼命令刪除系統中的應用程序? –

+1

通常你可以嘗試卸載,如果你不想搜索應用程序的路徑,如果應用程序已經安裝 'adb uninstall app_name' 雖然我想你想要從sys或priv-應用程序目錄,然後你可以在adb中使用以下刪除命令並嘗試鏈接以獲取更多詳細信息 'adb rm [-f/-r/-d] path_of_file' [link](http://adbshel​​l.com/commands/adb- shell-rm) –

+0

有無論如何得到一個應用程序的路徑,或者我應該從「/」搜索它? –

1

一點點搜索後在Android開發者網站我發現this package installer,這有助於安裝和刪除(其中包括)的應用程序。

public class PackageInstaller 
void uninstall (String packageName, 
      IntentSender statusReceiver) 

卸載給定包,從設備完全除去它。

我希望這可以滿足您的要求。

2

下面的代碼使用卸載用於分鐘API級別14

Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); 
intent.setData(Uri.parse("packageName")); 
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); 
startActivityForResult(intent, 1); 

Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
super.onActivityResult(requestCode, resultCode, data); 
if (requestCode == 1) { 
    if (resultCode == RESULT_OK) { 
     Log.d("TAG", "onActivityResult: user accepted the (un)install"); 
    } else if (resultCode == RESULT_CANCELED) { 
     Log.d("TAG", "onActivityResult: user canceled the (un)install"); 
    } else if (resultCode == RESULT_FIRST_USER) { 
     Log.d("TAG", "onActivityResult: failed to (un)install"); 
    } 
}} 
相關問題