Search code examples
androidandroid-serviceadb

Restarting SystemUI using am startservice


I have been trying to restart SytemUI using these in my app,but it is not working,am on Android 4.0.4.Any help?

am startservice -n com.android.systemui/.SystemUIService

It works in adb shell,but not in my app or in terminal on android.

Code I am using in my app:

Process mSuProcess; mSuProcess = Runtime.getRuntime().exec("su"); 

DataOutputStream mSuDataOutputStream = new DataOutputStream(mSuProcess.getOutputStream()); 

mSuDataOutputStream.writeBytes("am startservice -n com.android.systemui/.SystemUIService\n");

Solution

  • Run shell instead of su, like;

    Process mSuProcess;  mSuProcess = Runtime.getRuntime().exec("sh");