intent extra android code example

Example 1: intent android

Intent intent = new Intent(MainActivity.this,Activity.class);

Example 2: activity get extras

String id = intent.getStringExtra("id");
String name = intent.getStringExtra("name");

Example 3: intent android

Intent intent = new Intent(MainActivity.this,MainActivity2.class);
 intent.putExtra("key",value);
 startActivity(intent);
////////////////////
 String string =getIntent().getStringExtra("key");

Example 4: activity get extras

Intent intent = getIntent();

Tags:

Java Example