0

I am working on a watchface. I need to launch an activity in order to request runtime permissions for my watchface.

I can easily launch an activity from inside my watchface engine like so:

Intent permissionIntent = new Intent(
                getApplicationContext(),
                PermissionActivity.class);
        permissionIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(permissionIntent);

But I would like to get the result of this activity so I can transfer a new state to the engine.

I read that there is a startActivityForResult that would fit me but that is not possible because I am running this inside a service.

Is there maybe any other way ?

Jimmy Kane
  • 16,223
  • 11
  • 86
  • 117
  • Starting an activity may be a solution http://stackoverflow.com/questions/3448485/startactivityforresult-from-a-service – Devrim Apr 25 '16 at 14:20
  • @DevrimTuncer yeah read that but still that new activity would not be able to pass back the result to the service. So there is no point in that. – Jimmy Kane Apr 25 '16 at 14:23
  • There are ways to communicate between a Service and an Activity. You can start an activity[A] from your service, activity can start other activity[B] for result, when activity[A] gets the result, it can send it as a message to service and finish itself.http://stackoverflow.com/questions/2463175/how-to-have-android-service-communicate-with-activity – Devrim Apr 25 '16 at 14:27
  • @DevrimTuncer ah yes, that looks more like it although it adds more abstraction layers. I ll give it a try! Thank you very much! – Jimmy Kane Apr 25 '16 at 14:31

0 Answers0