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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:53:10+00:00 2026-05-18T02:53:10+00:00

I have searched and searched and I just can’t get this code to work.I

  • 0

I have searched and searched and I just can’t get this code to work.I have a main.xml layout and a setting.xml.I have some values I would like the Settings.class to change in my main apps class.Three string to be exact.

I have tried this simple test code in my main app class

settings.setOnClickListener(new OnClickListener(){

   @Override
   public void onClick(View v) {
    Intent intent = new Intent(v.getContext(), Settings.class);
     startActivityForResult(intent, 0);


   }
   });

//Then a function
 @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent intent){
      super.onActivityResult(requestCode, resultCode, intent);
      Bundle extras = intent.getExtras();
      String value = extras.getString("myKey");
      if(value!=null){
      Log.d("hmmm",value);
      }
  }
}

In my settings.class I have the following

 returnHome.setOnClickListener(new OnClickListener(){

    @Override
    public void onClick(View v) {
     Intent intent = new Intent();
     intent.putExtra("myKey", "YEAH"); 
                 setResult(RESULT_OK, intent);
                 finish();


    }

         });

Back in main app class it is not getting logged.

Like I said I have three string in the main class that I want settings class to change and send back.
Any help is greatly appreciated

  • 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-18T02:53:11+00:00Added an answer on May 18, 2026 at 2:53 am

    I have had success with the technique used in the Notepad tutorial where the information is placed in a Bundle and then added to the intent. See Step 10:

    Bundle bundle = new Bundle();
    
    bundle.putString(NotesDbAdapter.KEY_TITLE, mTitleText.getText().toString());
    bundle.putString(NotesDbAdapter.KEY_BODY, mBodyText.getText().toString());
    if (mRowId != null) {
        bundle.putLong(NotesDbAdapter.KEY_ROWID, mRowId);
    }
    
    Intent mIntent = new Intent();
    mIntent.putExtras(bundle);
    setResult(RESULT_OK, mIntent);
    finish();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let me just say that I have searched for information on this topic;
I have searched and can't find the assert to this. I know it must
i'm working on a project and i have some problems.I have searched but can
Just need to confirm one thing that i have searched enough on How can
I have searched everywhere but just can't seem to find the answer. Can you
I've searched SO but I just can't figure this out. The other questions didn't
I have searched around but can't find the answer to this relatively simple question;
I've searched and searched and for whatever reason I just can't seem to get
I have searched and found nothing on this. I would like some advice or
I have searched high and low for documentation on this, but I just cannot

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.