13 Şubat 2018 Salı

Android Dersleri 17 - getIntent(), Intent class'ının getExtras(), putExtra() ve getExtra() method'ları


17 - getIntent(),  getIntent().getExtras(),        new Intent(context, SomeActivity.class), intent.putExtra("someKey", someData), intent.getExtra("someKey")

 getIntent : Return the intent that started this activity.
If you start an Activity with some data, for example by doing
Intent intent = new Intent(context, SomeActivity.class);
intent.putExtra("someKey", someData);
you can retrieve this data using getIntent in the new activity:
Intent intent = getIntent();
intent.getExtra("someKey") ...
So, it's not for handling returning data from an Activity, like onActivityResult, but it's for passing data to a new Activity.


Hiç yorum yok:

Yorum Gönder