2016-07-15 113 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"); 
    } 
}} 
相关问题