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 8145129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:34:21+00:00 2026-06-06T13:34:21+00:00

I’m following this tutorial http://www.vogella.com/articles/AndroidIntent/article.html for having some data transfered to parent activity by

  • 0

I’m following this tutorial http://www.vogella.com/articles/AndroidIntent/article.html for having some data transfered to parent activity by calling an activity with startActivityForResult.

Basicly i’m trying to finish parent activity, on some buttons clicked but not onBackPressed. I do not know if there is a easier way or not. Like this:

MainPage to NewTarget
            NewTarget to Target

// onBackPressed
            Target to NewTarget

// onButtonClick on TargetActivity
            Target to MainPage

The problem is onActivityResult calls when i click the button on NewTarget activity, not on Target activity finish?? Shouldn’t it be opposite?

On “NewTarget” class, i’ve got a button which needs to call an activity onClick. And i also need some feedBack on activity, named “Target”, like it’s been finished by back button or some other way (which i need to finish that activity on some point click, and i called “finish()”)

From NewTarget activity:

public void savingClick(View v) {
    Intent targetIntent = new Intent(this, Target.class);
    targetIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(targetIntent, 5);
}

On Target activity:

@Override
public void finish() {
if(ClickCheck) {
    Log.d("Target","ClickCheck");
    // Prepare data intent 
    Intent data = new Intent();
    data.putExtra("returnKey", "click");
    // Activity finished ok, return the data
    setResult(RESULT_OK, data);
}
super.finish();

}

And finally on NewTarget activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d("NewTarget","requestCode: " + requestCode);
    Log.d("NewTarget","resultCode: " + resultCode);
    if(requestCode == 5 && resultCode == RESULT_OK) {
        Log.d("NewTarget","data: " + data.hasExtra("returnKey"));
        if(data.hasExtra("returnKey"))
            this.finish();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

And i check the values:

// these lines have appeared when i clicked on button to startActivityForResult
requestCode: 5
resultCode: 5
// ClickCheck line has appeared on Target activity finished.
// data: data.hasExtra("returnKey")); line has never been appeared.

So what’s the deal? What am i overlooking? Thanks in advance for your helps.

  • 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-06-06T13:34:22+00:00Added an answer on June 6, 2026 at 1:34 pm

    To do this:

    MainPage to NewTarget
            NewTarget to Target
    
    // onBackPressed
            Target to NewTarget
    
    // onButtonClick on TargetActivity
            Target to MainPage
    

    You don’t need to use startActivityForResult() unless you need to have some data returned from Target to NewTarget. The normal behaviour will be that pressing “back” in Target will just call finish() on Target and return to NewTarget (that seems to be what you want). To get the last behaviour you should just use the following code in Target.onButtonClick():

    Intent intent = new Intent(this, MainPage.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    

    This will finish both NewTarget and Target and then it will finish the current MainPage activity and create a new instance of the MainPage activity (if the launchMode of MainPage is “standard”).

    Try this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.