use startActivityForResult(intent) and implement onActivityResult(int requestCode, int resultCode, Intent data) method.
startActivityForResult(new Intent(this, YouClass.class), LOGIN_REQUEST); protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == LOGIN_REQUEST) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = settings.edit(); editor.putString("username", username); } } 2009/8/28 ragavendran s <sraghav.ra...@gmail.com>: > > How can i transfer username to next page by the Intent: > > package add.sam1; > > > import android.app.Activity; > import android.app.AlertDialog; > import android.app.Dialog; > import android.content.Intent; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > import android.widget.EditText; > > > public class user extends Activity { > /** Called when the activity is first created. */ > > > EditText username,pass; > Button enter; > public static String str1; > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > > username=(EditText)findViewById(R.id.username); > pass=(EditText)findViewById(R.id.pass); > enter=(Button)findViewById(R.id.enter); > > enter.setOnClickListener(new OnClickListener() { > public void onClick(View v) { > > str1=username.getText().toString(); > String str2=pass.getText().toString(); > > if(str1.equals("raghav") && str2.equals("123")) > { > > showint(); > > > > > } > > else > { > Dialog locationError = new AlertDialog.Builder( > user.this).setIcon(0).setTitle( > "Error").setPositiveButton("ok", null) > .setMessage( > "Sorry, your u r not a Valid User") > .create(); > locationError.show(); > username.setText(""); > pass.setText(""); > } > > > > } > > > }); > > > } > > public void showint( ) > { > Intent intent = new Intent(this,welcome.class); > > startActivity(intent); > > > > } > > > > } > > > > -- Panut Sunyakorn 087-800-3456 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---