I'm trying to open the settings app from inside my sample app. Code snippet inside onCreate:
Process process;
try {
process = Runtime.getRuntime().exec("am start -a android.intent.action.MAIN -n com.android.settings/.Settings");
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s = reader.readLine();
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
}
catch(Exception e) {
e.printStackTrace();
}
When I run this, my app opens, but settings app does not start (neither does any other app I try). The toast inserted for debugging displays "Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.Settings } but it doesn't actually start. Nothing useful visible in logcat either (unless I've missed something in it)
I'm using Android Studio and an Android 4.4 device if that matters. I've been searching online to figure out what I might be doing wrong, but things seem correct in the above code. Could someone please help?
0 comments:
Post a Comment