You can use static Method to get data from one activity to another activity.Below is sample code
First Activity
public class First extends Activity {
static First INSTANCE;
String data="FirstActivity";
@Override
public void onCreate(Bundle savedInstanceState) {
INSTANCE=this;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public static First getActivityInstance()
{
return INSTANCE;
}
public String getData()
{
return this.data;
}
}
Second Activity:
public class Second extends Activity {
String data;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
data=First.getActivityInstance().getData();
Toast.makeText(Second.this,"Data from first activity is"+data, 1).show();
}
}
Hope it helps you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…