Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6385853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:57:05+00:00 2026-05-25T02:57:05+00:00

How to wait to another activity result in android. I have written the following

  • 0

How to wait to another activity result in android.
I have written the following code but after the activity finishes, it always goes to onCreate() method.

I have tab activity.From one tab activity , i called another activity, that is popup window……After finished popup window It should go back to previous activity

   @Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    Object o = this.getListAdapter().getItem(position);
    keyword = o.toString();
    positions = position;

    if(position != 0 ){
        Bundle bundle = new Bundle();

        Intent showContent = new Intent(getApplicationContext(),SalesRouteDevitionActivity.class);
        int postion = position;
        String aString = Integer.toString(postion);
        bundle.putString("positon", aString);
        showContent.putExtras(bundle);
        startActivityForResult(showContent,0);
    }else{

        Intent intent = new Intent(SalesRouteActivity.this, ListRetailerActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("RouteName", keyword);
        intent.putExtras(bundle);
        View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();  
        SalesActivityGroup.group.replaceView(view);
    }
}


   @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {  

       Log.w("onActivityResult" ," --requestCode ---" + requestCode + " -- resultCode -- " + resultCode + " -- data --" + data);
      if(resultCode==0){
          Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
          if(resultCode==RESULT_OK)
              Toast.makeText(this, "Reason has been successfully.", Toast.LENGTH_LONG).show();
         else
              Toast.makeText(this, "Fail", Toast.LENGTH_LONG).show();
      }
  }

and SalesRouteDevitionActivity.class

    public class SalesRouteDevitionActivity extends Activity {
private String array_spinner[];
String param1 = "";
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.route_diviation_popup);
    array_spinner=new String[2];
    array_spinner[0]="Rain";
    array_spinner[1]="Floods";

    Spinner s = (Spinner) findViewById(R.id.spinner1);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_dropdown_item, array_spinner);
    s.setAdapter(adapter);
    Button button = (Button) findViewById(R.id.submit);

     button.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {


             Intent mIntent = new Intent();
             setResult(RESULT_OK);
             finish();



         }
     });

}

}

This is my Tab Activity.I am using ActivityGroup

  public class MainActivity extends TabActivity {
int selectedTab;
TabHost tabHost ;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabview);

    TabHost t = getTabHost();
    tabHost = (TabHost)findViewById(android.R.id.tabhost);

    TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
    TabSpec secondTabSpec = tabHost.newTabSpec("tid1");
    TabSpec thirdTabSpec = tabHost.newTabSpec("tid1");
    /** TabSpec setIndicator() is used to set name for the tab. */
    /** TabSpec setContent() is used to set content for a particular tab. */
    firstTabSpec.setIndicator("Sales").setContent(new Intent(this,SalesActivityGroup.class));
    secondTabSpec.setIndicator("Admin").setContent(new Intent(this,SettingActivityGroup.class));
    thirdTabSpec.setIndicator("Setting").setContent(new Intent(this,SettingActivityGroup.class));


    tabHost.addTab(firstTabSpec);
    tabHost.addTab(secondTabSpec);
    tabHost.addTab(thirdTabSpec);
    tabHost.setCurrentTab(0);
    tabHost.setMinimumHeight(25);
}

public void onTabChanged(String arg0) {
        selectedTab = tabHost.getCurrentTab();

}

This is SalesActivityGroup.java

 public class SalesActivityGroup extends ActivityGroup {

public static SalesActivityGroup group;
private ArrayList<View> history;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.history = new ArrayList<View>();
    group = this;

    View view = getLocalActivityManager().startActivity("Sales",
            new Intent(this, SalesRouteActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
            .getDecorView();

    replaceView(view);

}

public void replaceView(View v) {
    history.add(v);
    setContentView(v);

}

public void back() {
    if (history.size() > 0) {
        history.remove(history.size() - 1);
        if (history.size() > 0) {
            setContentView(history.get(history.size() - 1));
        } else {
            finish();
        }
    } else {
        finish();
    }
}

@Override
public void onBackPressed() {
    SalesActivityGroup.group.back();
    return;
}

}

I know this is the way we should do, but really i dont know why its not working my part….

I didn’t go to onActivityResult() method & it didnt print Log also

Please help me..

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:57:06+00:00Added an answer on May 25, 2026 at 2:57 am

    If you are using tab ActivityGroup then should use like this:

    Calling activity:

     Intent showContent = new Intent(botton.getContext(),RetailerOrderEActivity.class);
     getParent().startActivityForResult(showContent, 2);
    

    consider getParent(), If it is Tab activityGroup then call like that.

    and child Activity:

        Intent i = new Intent();
        Bundle bundle = new Bundle();
        i.putExtras(bundle);
        setResult(Activity.RESULT_OK, i);
        finish();
    

    after finish this will go to ActivityGroup class:

    there you want to call like this:

      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    
        if(requestCode ==1){
            Bundle bundle = data.getExtras();
            String roteCode = bundle.getString("RouteCode");
            Intent intent = new Intent(SalesActivityGroup.this,ListRetailerActivity.class);
            bundle.putString("RouteCode", roteCode);
            intent.putExtras(bundle);
            View view = SalesActivityGroup.group.getLocalActivityManager().startActivity("",intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
            SalesActivityGroup.group.replaceView(view);
        }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need this button, to wait with proccesing to another activity (secondclas), for the
all i want block of code wait for another thread to die where this
I have an object on thread A that is calling wait() while another object
I saw the following code, and wanted to use it for a simple activity
How can I use an ArrayAdapter from another activity? I tried doing the following
I am using below code from one of my activity to start another Intent
I have some code which I think should compile, but doesn't: import java.io.InputStream; import
How can I make a batch file wait until another batch file has finished?
Is there a better way to wait for queued threads before execute another process?
I want to wait for a process to finish, but Process.WaitForExit() hangs my GUI.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.