So in the documentation here
http://developer.android.com/google/play-services/setup.html
it says to check the status of play services with isGooglePlayServicesAvailable() and then display the error dialog if it's not okay.
This seems to be working fine for me, the dialog showing it's not installed with a button that opens up the play store all seems okay. My question is specifically about the returned results in onActivityResult().
We have to pass a requestCode to getErrorDialog() and I get that back in onActivityResult just fine, but im more concerned with the resultCode returned. So far with all my testing I've gotten 0 (RESULT_CANCELLED). I was wondering if there was any way to know if the play services were installed successfully?
For now I'm handling it by just assuming that RESULT_CANCELLED means that they at least got to the play store and started downloading, and display another dialog that says "please restart this app once the play services complete installation" followed by a finish().
Is this the best way to handle it? or is there a case that I'm missing where it will return RESULT_OK and I can just continue onward with my app working without restarting it?
I must say that today I tried it, and I never got onActivityResult() called.
When dialog is cancelled, my OnCancelListener (getErrorDialog() parameter) is called, and when returning from PlayStore, whether installing Google Play Services or not, my app is destroyed.
Even more, when installing Google Play Services, onDestroy() is called when installation starts.
I think maybe this is an updated behaviour, and I think is consequent, because you can return from Play Store before background installation ends.
Nonetheless, I found a couple of links with sample code that may confirm in case onActivityResult() is called with RESULT_OK, it means that you can continue:
http://developer.android.com/training/location/activity-recognition.html
http://developer.android.com/training/location/retrieve-current.html
Hope it helps
Related
When Users downloads the app via Flexible app update
appUpdateManager?.startUpdateFlowForResult(it, AppUpdateType.FLEXIBLE, activity, REQUEST_CODE_FLEXI_UPDATE)
but forgets or accidentally skips to click the restart app button which does following:
appUpdateManager?.completeUpdate()
Then app update is not available. Even I tried with clear app data, it doesn't work. Looks like once app is downloaded via inappupdate and skips installation, you're stuck, it doesn't ask again.
appUpdateManager?.appUpdateInfo?.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {
updateAvailable.value = true
}
}
Is there a solution to this? Other things are working and it's live on playstore just looking for solution of such use-case.
Also how to get progress value of app being downloaded, couldn't find it in documentation. In my case, onActivityResult keeps calling but which key gives progress value?
Also facing another issue with different use case: java.lang.reflect.InvocationTargetException while inappupdate android if retries
You should check for appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED on app restart and call completeUpdate() at some point as per the documentation.
I found out that the Play-Game-Services Integration with GetServerAuthCode Integration does have an error when the following situation:
After I finish the integration and i call getServerAuthCode, it
bring me the AuthCode value.
After I close the app in the background and i re-open the app, the silentSignIn always fail.
Now I can't retrieve my AuthCode unless I re-signIn the app, this cause an issue as player need to always re-signIn the app when starting of the app. It doesn't bring a good User Experience.
I wish to know that is there something that i miss out during the integration? Or it is an intended feature? If it is an intended feature, is there any solution/work-around that can help me solve my issue?
I am using OpenIAB to support in app purchasing in my app (OpenIAB uses google code to implement IAP for Google Play Store). The problem is that, sometimes, when i call launchPurchaseFlow(), the method onActivityResult() of my FragmentActivity is not called. Checking the logs, i have found that when this happens there is always the following msg:
W/ActivityManager( 319): startActivity called from non-Activity
context: forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent {
cmp=com.android.vending/com.google.android.finsky.billing.lightpurchase.IabV3Activity
(has extras) }
When this happens, i have to close the app. Usually it start working again after some time (i have absolutely no clue of why is it so).
I don't know why this message show up, since the context is obviously my activity (and in fact it works most of time). I have to say that the .apk installed on my device is an updated verion with respect to the apk uploaded in the beta version of the developer console and that i am using my google developer account to test IAP. This implies that i cannot make any real buy. However, this is not important, since i am testing the app.
These are my questions:
Is it true that starting an activity for result with
FLAG_ACTIVITY_NEW_TASK prevents onActivityResult() to be called?
How do you explain that message?
Regarding the first question, i have tested with launchMode=singleTask and the behaviour is the same of launchMode=singleTop.
I'm currently create an application that have the possibility to updated from own code thanks to a downloaded .apk from a server.
I would like to know if the update/Install of the app is successfull. Because currently the update working fine but i don't know if the installation/update is ok or not, if the installation face a problem or if the user cancel install or somethings else. So i need to have a callback "installFinish(boolean isOk)".
i search for a day but i don't find solution for my problem.
I read lot of things, particulary this :
How to find out when an installation is completed
or this :
Android - Install Application programmatically with result
but is not what i seach.
This is my code for update my app
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file.getAbsoluteFile()), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
((Activity) context).startActivity(intent);
EDIT
I tried this https://stackoverflow.com/questions/29175722/how-to-get-onactivityresult-called-from-action-view-intent
but it's not working for me for two reason i think:
I don't know whether the user pressed Cancel
onActivityResult is never call after updated the same app, maybe because it's the same app which updated the app who launch the intent is kill. ?
Maybe the last reason it's the same reason why i don't receive broadcastevent such as listening for ACTION_PACKAGE_ADDED in the app who launch the update.
Maybe i can call the method when the first time the application is launch, it's like install is successfully because the app is started.
Heres a work around which we use:
Implement a dummy provider and override onUpgrade().onUpgrade is called whenever database is upgraded.U will need maintain one to one mapping between database version and app version.
I have an Android app, working with a custom receiver. It was working without problem, but with the release of the new cast companion library, I decided to upgrade it, as well as my Play services version.
Anyway, when I try to connect to Chromecast, my custom receiver HTML page is displayed. But then, I can't connect and send data to it. After a while (something like 15 seconds), the app exits on the Chromecast.
Then, I've tried to get the Cast Hello Text sample to work, using the same app id. Same problem here.
Here is the code I use to launch the Cast app:
Cast.CastApi.launchApplication(mApiClient, getString(R.string.app_id), true)
The result I receive in the ResultCallback, is a status with code 15, with isSuccess method returning false.
The problem doesn't seem to come from my Chromecast, since other users have the exact same issue.
Thanks for your help!