0

I need to pass the variable from onCreate method to OnClickListener...

// onCreate method
String num2 = bundle.getString("phno"); 

// onClickListener method
s.sendTextMessage(no,null,msg,null,null);

here in "no" place i need to use the String which i get in the Oncreatemethod from another activity...i know that navigating the activities using bundle and i used that method here... i need help in "num2" which i get in the oncreate method to onclick listener in "no" place....

i tried simply with String no=num2; but it doesnt work

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
  • 1
    Usual way is to use an intent to pass data between activities, see this post: http://stackoverflow.com/questions/4233873/how-to-get-extra-data-from-intent-in-android – Daniel Nugent Feb 25 '15 at 19:36
  • Indeed, arguments from another activity come as part of an Intent - the bundle would not have that, but rather potentially the saved state of your instance. – Chris Stratton Feb 25 '15 at 19:48

1 Answers1

1

declare String "no" globally..

devcodes
  • 1,038
  • 19
  • 38