You should change the following:

                static final String CONTACT_NAME = null;
                static final String CONTACT_PHONENUMBER = null;

into this:

                static final String CONTACT_NAME = "I_am_so_silly";
                static final String CONTACT_PHONENUMBER =
"these_strings_should_be_different";

or into this:

                static final String CONTACT_NAME = "contact_name";
                static final String CONTACT_PHONENUMBER =
"contact_phonenumber";

Otherwise you just retrieve the extra for the value 'null'.

Peli ;-)

On Dec 17, 10:13 am, "Ashok Kumar" <[email protected]> wrote:
> Hi,I am trying to pass two variables from one screen (ContactsView.java )to
> second screen (NewContact.java)
>
> In ContactsView.java I am passing two values as shown below:
>
>                 static final String CONTACT_NAME = null;
>                 static final String CONTACT_PHONENUMBER = null;
>
>                 Intent intent =  new Intent(this,NewContact.class);
>  String strName = "NAME";
> String strPhoneNumber = "PHONENUMBER";
>  intent.putExtra(CONTACT_PHONENUMBER, strPhoneNumber);
>  intent.putExtra(CONTACT_NAME, strName);
>  startActivity(intent);
>
> In NewContact.java I am receiving the values as shown below:
>
>                 Bundle extras  = getIntent().getExtras();
>                 if(extras != null){
> contactName  = extras.getString(ContactsView.CONTACT_NAME);
>  contactPhoneNumber = extras.getString(ContactsView.CONTACT_PHONENUMBER);
> System.out.println("----------- Name  is              -->"+ contactName);
>  System.out.println("----------- PhoneNumber is  -->"+ contactPhoneNumber );
>  }
>
> But at the println statements i am seeing
> ----------- Name  is              --> NAME
> ---------- PhoneNumber is  --> NAME
>
> What i observed is : The last putExtra is stored in all the variables. (i.e)
> If i use intent.putExtra(CONTACT_PHONENUMBER, strPhoneNumber) as the last
> statement. Then all the variables are having the values of phone number.
>
> Can any one please help me out in passing the values from one screen to
> another screen.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to