miércoles, 1 de enero de 2020

Passing Data To Other Activity Using Intent.

  1. Create a New Explicit or Implicit Intent object in source activity.
  2. Call intent.putExtra(String key, Object data) method to save data in it.
  3. Call startActivity(intent) method in source activity to pass the intent to android os.
  4. Call getIntent() method in target activity.
  5. Use intent.getStringExtra(String key) to get the transferred data.
This-

Intent intent = new Intent(this, BasicViewsActivity.class);
intent.putExtra("amountTime", String.valueOf(amountTime));
startActivity(intent);

BasicViewActivity-

Intent intent = getIntent();
String amountTime =   intent.getStringExtra("amountTime");


https://www.dev2qa.com/passing-data-between-activities-android-tutorial/

No hay comentarios:

Publicar un comentario