2011/03/07

[Android Dev.] Activity 간 데이터 주고 받기

다른 Activity에 데이터 넘겨주기


Intent intentSubActivity = new Intent( this, SubActivity.class );

intentSubActivity.putExtra( "Name", "Intent Data" );
intentSubActivity.putExtra( "Age", 30 );
intentSubActivity.putExtra( "Marriage", false );

startActivity( intentSubActivity );





넘어온 데이터 받기


Intent intent = getIntent();

String strName = intent.getStringExtra( "Name" );
Integer nAge = intent.getIntExtra( "Age", 0 );
Boolean bMarriage = intent.getBooleanExtra( "Marriage", false );

String strMsg;
strMsg = "Name : " + strName + " Age : " + nAge + " Marrige : " + strMarriage;
Log.i( "SubActivity", strMsg );

INFO/SubActivity(xxx): Name : Intent Data Age : 30 Marrige : X

Original Post : http://neodreamer-dev.tistory.com/515

No comments :

Post a Comment