Intent.setData vs Intent.putExtra

后端 未结 4 608
长发绾君心
长发绾君心 2020-12-09 15:44

I\'m trying to follow this tutorial:

http://www.vogella.com/articles/AndroidCalendar/article.html

I understand what putExtra does

but I fail to under

4条回答
  •  感动是毒
    2020-12-09 16:27

    I've found a good answer here: https://google-developer-training.gitbooks.io/android-developer-fundamentals-course-concepts/content/en/Unit%201/21_c_understanding_activities_and_intents.html

    Use the intent data field (Intent.setData): - When you only have one piece of information you need to send to the started activity. - When that information is a data location that can be represented by a URI.

    Use the intent extras (Intent.putExtra): - If you want to pass more than one piece of information to the started activity. - If any of the information you want to pass is not expressible by a URI.

    Intent data and extras are not exclusive; you can use data for a URI and extras for any additional information the started activity needs to process the data in that URI.

提交回复
热议问题