enable App from Shell - Android App

Android examples for App:App Running

Description

enable App from Shell

Demo Code


//package com.java2s;

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    public static void enableApp(String packageName) {
        Process p;/*  w w w . j a v  a  2  s  .  c  om*/
        try {
            p = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(p.getOutputStream());

            os.writeBytes("pm enable \"" + packageName + "\"\n");
            os.writeBytes("exit\n");
            os.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials