i have value of a variable 'position' in my oncreate which i got it from a different activity using getIntent(). now i want to use the value of this position in a different method.
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tatslideshow);
Intent j = getIntent();
int position = j.getExtras().getInt("pos");
}
and i want to use position in this method
public void updateUI() {
int imgid[] = alltats[position];
.
.
.
}
now i know i can pass the value by putting parameters in updateUI() like updateUI(position) and use it. but the problem is i also have a subclass in my class where i am calling this method so i cant put parameters in updateUI(). this is the subclass:
class RefreshHandler extends Handler {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
TatSlideShow.this.updateUI();
}
}
TatSlideShow is the main class. please tell me the way to achieve it.
You can call
getIntent().getExtras().getInt("pos")fromupdateUI()directly, sinceupdateUI()is a non static method of your Activity.