5

I have a screen where I store a phone number then go to another screen and launch the main part of the activity where I send a text massage where I am trying to get the number I entered in the first activity. I have all the code in to send message but it will not get the number from the previous activity. Here is my code form the first activity:

public class StoreNumberActivity extends Host_Setting_PageActivity {
     /** Called when the activity is first created. */
    @Override


     public void onCreate(Bundle savedInstanceState) {
            super.on``Create(savedInstanceState);
            setContentView(R.layout.notificationsettings);

            final EditText editText= (EditText) findViewById(R.id.HostPhoneNumber);

             //Juston class to schedule edit
            Button Save = (Button) findViewById(R.id.SaveBtn);
            Save.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    Toast.makeText(StoreNumberActivity.this, "Number was Saved Successfully", Toast.LENGTH_LONG).show();

                }
            });
             Button Send = (Button) findViewById(R.id.SendBtn);
              Send.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View view) {
                      String Number  =  editText.getText().toString();
                      Intent myIntent = new Intent(StoreNumberActivity.this, Host_Setting_PageActivity.class);
                      myIntent.putExtra("Phone Num", Number);
                      startActivity(myIntent);
                  }


and my code from the second activity:



 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    /** setting the view of the activity to xml */
    setContentView(R.layout.messageme);
    final Bundle bundle = getIntent().getExtras();

    final EditText editText= (EditText) findViewById(R.id.yourname);
    final EditText phonenumber= (EditText) findViewById(R.id.phone);
    final EditText emailaddress= (EditText) findViewById(R.id.email);
    final EditText messagebox= (EditText) findViewById(R.id.messages);
    final EditText number = (EditText) findViewById(R.id.HostPhoneNumber);

    button= (Button) findViewById(R.id.btn);
    button.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
    // TODO Auto-generated method stub
        Intent myIntent = getIntent(); // this is just for example purpose
        myIntent.getStringExtra("PhoneNum");
        String Number = bundle.getString("Phone Num");
        String Name  =  editText.getText().toString();
        String Phone  = phonenumber.getText().toString();
        String Email  = emailaddress.getText().toString();
        String Message  = messagebox.getText().toString();



        sendSMS(Number, "Name: " + Name + "\n" + "\n" + "Email: " + Email + "\n" + "\n" + "Phone: " + Phone + "\n" + "\n" + Message);
    }
user1424296
  • 61
  • 1
  • 2
  • 3

1 Answers1

3

Here are a couple of StackOverflow answers that might give you what you need:

pass value between activity android

How do I pass data between activities in Android?

Community
  • 1
  • 1
Ken Cenerelli
  • 550
  • 1
  • 9
  • 22