I am looking to integrate an application with Google Play Services and Mortar to retrieve the user's current location.
https://developer.android.com/training/location/retrieve-current.html#CheckServices
This requires handling onActivityResult() in the case that Google Play Services is not available.
My first instinct on how to do this is to make getFirstScreen()
in Main.java
return a blank loading screen.
https://github.com/square/mortar/blob/master/mortar-sample/src/main/java/com/example/mortar/core/Main.java
After injection, during onCreate()
perform the check to see if Google Play Services is available. If it is, then call flow.goTo(<location using screen>)
, if not, do nothing and wait for onActivityResult()
to be called. Then, when onActivityResult()
fires, simply call flow.goTo(<location using screen>)
.
The above seems slightly hacky to me. (Let me know if you need clarification). So I'm thinking the other solution might be to do something similar to this Mortar + Flow with third party libraries hooked to activity lifecycle and hook up onActivityResult()
to the presenter. The problem with this is that I won't have access to the Activity
from a presenter which makes it impossible to call GooglePlayServicesUtil.getErrorDialog(...)
because it requires Activity
.
I think onActivityResult()
is very important. Perhaps it should be a part of the Mortar library?