android - 从应用程序执行pm grant

时间:2016-08-18 11:20:53

标签: java android shell permissions adb

我想执行命令" pm grant com.example.xy android.permission.CHANGE_CONFIGURATION"在应用程序内部。

     Process p;
     try {
         p = Runtime.getRuntime().exec("pm grant com.example.xy android.permission.CHANGE_CONFIGURATION");
         p.waitFor();
         BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

         String line = "";
         while ((line = reader.readLine())!= null) {
             output.append(line + "n");
             Log.e("splash", "error " + output.append(line + "n"));
         }

     } catch (Exception e) {
         Log.e("splash", "error " + e.toString());

         e.printStackTrace();
     }
     String response = output.toString();
     return response;

这没有效果。 有谁有解决方案吗?

0 个答案:

没有答案