2

I've been reading about deep linking into my application, and everything I've looked at has said something like:

"Call the getData() and getAction() methods to retrieve the data and action associated with the incoming Intent. You can call these methods at any time during the lifecycle of the activity, but you should generally do so during early callbacks such as onCreate() or onStart()."

My question is why? If I can call them at any time, then what makes the early callbacks the best time?

DMR0585
  • 21
  • 2
  • Do you have links to any of these places that make this recommendation? Perhaps there is something in context there that we're missing. – CommonsWare Apr 19 '16 at 00:43
  • https://developers.google.com/app-indexing/android/app#add-intent-filters-for-http-urls, http://developer.android.com/training/app-indexing/deep-linking.html, http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser/2958870 – DMR0585 Apr 19 '16 at 00:44
  • OK, I'm not sure why they are making those recommendations. The first link is screwed up in other ways, making it seem like `onNewIntent()` is just some helper method, when it is really another entry point where you may get an `Intent` that you need to deal with. – CommonsWare Apr 19 '16 at 00:50

1 Answers1

0

IMHO, to think each Activity or Fragment is a small piece of executable logic (it's logical to think as it is because both have own lifecycle), we can think getData as arguments input which affects to the content for showing up.

As OnCreate gives a change before UI construction, so that we can process additional information for showing user interface and its content.

Or we can say, as a UX perspective, user might not want to see contents filling but just filled on the screen right after the Activity/Fragment drawn.

Youngjae
  • 24,352
  • 18
  • 113
  • 198