I just figured out how to have the android app post a dialog box asking for permission and to only execute a specific command when the user hits allow. But I am stuck on having the app restart after that, due to the android bug the app doesn't have permission unless restarted.
Code like doesn't seem to be working. The app reboots but leaves off where it was at; keeping the same preferences assigned by the device on the first launch.
// Schedule start after 1 second
PendingIntent pi = PendingIntent.getActivity(this, 0, getIntent(), PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
am.set(AlarmManager.RTC, System.currentTimeMillis() + 10000, pi);
// Stop now
System.exit(0);
Is there a different way to restart the app, one that would work to allow the phone to tell the app it has permission to do certain things.