views:

135

answers:

1

Hi,

I need to pass a value back to the same activity and refresh the activity to generate new data. Can anyone please provide me some ideas/guidance on how to do it? Thank you. I had try using intent to call the same activity but it doesn't work. Here is the code which i tried to use intent:

btn_next = (ImageButton) findViewById(R.id.btn_next);
        btn_next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                page_counter = page_counter + 1;
                if (page_counter > 1){
                        btn_prev.setEnabled(true);
                }
                 Intent i = new Intent();
                 i.setClassName("sample.android.androidgallery","helloAndroid");
                 i.putExtra("page",wallpaper_page_counter); //to pass this activity's data to next
                 startActivity(i);
            }
        });
A: 

Intent intent = new Intent(); Bundle bundle = new Bundle();

bundle.putXXX(key,value);

intent.setClassName(MainActvity.this,MainActvity.class); intent.putExtras(bundle); startActivity(intent);

AmitDroid