-
Notifications
You must be signed in to change notification settings - Fork 2
Intent Extra Binding
Steven Lewi edited this page Jul 13, 2015
·
4 revisions
@IntentExtra
can be used to bind Activity's Extra. It has same functionality as getIntent().get...Extra("key");
@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity {
@Override
protected void onContentViewCreated() {
}
@OnClick(R.id.button1)
public void onButton1Clicked() {
Intent i = new Intent(this, SecondActivity.class);
i.putExtra("id", 1);
i.putExtra("full_name", "John Doe");
i.putExtra("user_profile", new Profile());
startActivity(i);
}
}
public class Profile implements Serializeable {
public String name;
public String address;
}
@ContentView(R.layout.activity_second)
public class SecondActivity extends BaseActivity {
@IntentExtra("id")
private int id;
@IntentExtra("full_name")
private String fullName;
@IntentExtra("user_profile")
private Profile userProfile;
@Override
protected void onContentViewCreated() {
Toast.makeText(this, fullName, Toast.LENGTH_SHORT).show();
}
}
For fragment arguments/parameters, take a look into this.