Here i wrote a code to pass data from one activity to another activity by using intents.. Please let me know if i need to do any corrections over here in my code.
OnClickListener buttonListener = new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent nextIntent = new Intent(getApplicationContext(), SecondActivity.class);
nextIntent.putExtra("firstname", "Siva");
nextIntent.putExtra("Secondname", "Kumar");
startActivity(nextIntent);
Toast.makeText(getApplicationContext(),"SignIn Button Clicked", Toast.LENGTH_SHORT).show();
}
};
Second Activity:
OnClickListener backListener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent backIntent = new Intent(getApplicationContext(), MainActivity.class);
Intent receivedIntent = getIntent();
Bundle bundleData = receivedIntent.getExtras();
bundleData.getString("firstname");
bundleData.getString("secondname");
startActivity(backIntent);
}
};