Run extended Application.class when app update - java

I have an application on Google Play. And now I want to integrate push-notification library in my application. So I initialize this and register user in my class extended Application.class. Some people update application on Google Play automatically and not open this. And registration on push-services will be only when user launch application. So I want that my class with init library and register user in push-service will be run when application updated from Google Play. Is it possible?

Use a BroadcastReceiver with this action: android.intent.action.PACKAGE_REPLACED (How to know my Android application has been upgraded in order to reset an alarm?).
You can register a user once onReceive is called. It will be triggered even if the app is closed because the receiver is registered in AndroidManifest.xml. Just make sure it's not triggered while updating other apps.

Related

How to send downtime message from services to use it in mobile app

I am developing services/api's which are being used in mobile application. Mobile app calling those services and binding the data.
I want to write services in a way so that if donwtime/maintenance is going on mobile app should bind to a particular screen.
How can I develop this structure across the services, How can I do that?
Maybe you can create an API which can provide details like if service is up or not.
On launch of your mobile app, in loading screen or splash screen, you can check if your service is up or not!
Based on the the response, you can show respective screen on mobile.
If your new service also not responding, you can set timeout on mobile app to show generic error!

How to update my location on activity when I am on other application

I have an app that the activity sends the user location to the server, how do I get the activity to keep sending the location to the server even when the application is in the background and the user is currently using another app?
For example
I need that my application will work something like in WhatsApp "share my current location live" or Yango that even if the driver is on navigation and the app is in the background the user still gets the driver current location.
Basically, create a Service which is going to be reading the location and doing that. It get's a bit more complicated because Android added restrictions to background services and the rate at which apps in the background can get updates on new device location. This explains about services. The service will be started from the activity. The service will contain the code for fetching the locations

How to tell if first Facebook log in - Android

I am attempting to integrate onboarding screens into my Android application that allows users to register through Email/Password, or through Logging in with Facebook.
Is there any way of programmatically knowing when the user logs in through Facebook whether it is the first time of doing so?
I only want the Onboarding Activity to launch the first time the user logs in through Facebook (after accepting the permissions request), not every time they log in.
Any help with this issue would be hugely appreciated.
use facebook API's to authenticate the users.Login to the facebook developer console to register your application and get the key hashes that will uniquely define your application.
Use facebook Api by this link https://developers.facebook.com/ register your app.
and follow the instruction as mentioned.Then you can integrate facebook logging in your App

Handle onMessageReceived() and onTokenRefresh() even if the app is not running

I have an app with 2 services :
MessagingService extends FirebaseMessagingService
and
InstanceIDService extends FirebaseInstanceIdService
There are declared in the AndroidManifest.xml file.
The problem is that when my app's process is forced close itself, the services are also killed.
I'd like them not to be killed. I've heard about the START_STICKY flag for the Service class, but I can't override the onStartCommand() method in these services so as to return this flag...
To answer to the comments, I didn't find any "solution" to my problem because it's not a problem. If the user wants to close my app, he has the right to.
Since my onMessageReceived() method belongs to my MessagingService in my app, if the app is force-closed by the user, neither the app nor the service will restart.
As Weishi Zeng said in the comments, the "settings force close" stops all about my app including the services, so the notification is received by the Google Play services but my app isn't here to see it. Then the onMessageReceived() method is not executed.
However the service is not closed with the "swipe close".
Eventually, I didn't want to find any workaround since this would be contradicting the user choice.
See here.

Google Play Services (RESULT_LICENSE_FAILED)

I have created an app and a service (service for Leaderboard), everything works fine with leaderboard when i am signed in with my tester google account. When i change to another account it show me:
RESULT_LICENSE_FAILED Error=3 Code=10003
p.s.1 My service is fully published
p.s.2 My updated app (implementing Google Play Services -Leadeboard) is not published at Play Store.
Do you think that if i publish my updated app will be working fine, or i have to check something else?
Enabling anti piracy in the linked application when you setup your game could cause this, see https://developers.google.com/games/services/android/antipiracy
This can cause that error when not downloading the app from the play store.

Categories

Resources