Why is com.facebook.Settings.publishInstallAsync in onResume?

I looked at the Facebook SDK 3.0 to try and figure out how to track the installations coming from the Facebook campaign, and saw this in the documentation:

For the FB Android SDK 3.0, add the following to onResume () of each activity in your application: com.facebook.Settings.publishInstallAsync (context, YOUR_APP_ID);

I have two main questions:

  • Why does this happen in every action, and not in launch activity?

  • Why does this happen in the onResume method instead of onStart ? Android recommends not doing such things in onResume .

Edit - even though asynchronously doing this again and again seems silly and optional

+7
source share
1 answer

The answer to both questions is that by including a call in the onResume () method for each operation, you are dealing with network crashes while the user first starts the application. In other words, your application will try to publish the installation every time the action is displayed in the foreground, and not just the first time the Activity starts.

From Facebook Mobile app developers to install apps :

This will allow the application to track the installation event on Facebook when the user first opens the application, and again in the future if there is a network error. Our client code will stop sending installations after it has acquired a success code from the server, and our internal server will only count once if it receives several requests for the same device.

+2
source

All Articles