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

  • Home
  • SEARCH
  • 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 7847089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:47:05+00:00 2026-06-02T17:47:05+00:00

I want to pass a string from 1 activity to another, although I have

  • 0

I want to pass a string from 1 activity to another, although I have taken reference from many accepted answers from other threads, I am facing problem that I am not able to debug. When I comment extras.putString as shown in code below, Toast message shows the correct address which means value is being set properly and code works fine but when I use extras.putString(), I get NullPointerException and application closes due to exception. There are many \n characters in my address string. Infact even if I use extras.putString(“userAddress”, “test”) I get NullPointerException

Here is my Main Activity from which I want to call FBShare Activity:

Intent mIntent = new Intent(this, FBShare.class);   
Bundle extras = mIntent.getExtras();
String currentAddress = getCurrentAddress(ourLocation);
Toast.makeText(getBaseContext(), getCurrentAddress(ourLocation), Toast.LENGTH_SHORT).show();
extras.putString("userAddress", currentAddress);
startActivity(mIntent);

And in FBShare Activity I am trying to fetch values as follows

strAddress = getIntent().getExtras().getString("userAddress");  

Here is one thread which is doing similar thing.

  • 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-02T17:47:05+00:00Added an answer on June 2, 2026 at 5:47 pm

    try my code

    Intent mIntent = new Intent(this, FBShare.class);   
    Bundle extras = new Bundle();
    String currentAddress = getCurrentAddress(ourLocation);
    Toast.makeText(getBaseContext(), getCurrentAddress(ourLocation), Toast.LENGTH_SHORT).show();
    extras.putString("userAddress", currentAddress);
    mIntent.putExtras(extras);
    startActivity(mIntent);
    

    hope this will work.

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

Sidebar

Related Questions

I have a problem(again)...now i want to pass a String from one Activity to
i want to pass a string value from one page to another.Also i have
Well, I want to pass a string value from one file to another, how
Hi I want to pass an Arraylist from one activity to another. I use
i want to pass a string from an input box that after submition automatically
I have the following scenario where I want to pass in string and a
I want to pass XML as a string in an XML attribute. <activity evt=&lt;FHS&gt;
i have a NSData object. I want to convert it to a string, pass
I am trying to create an Activity class from a string and pass it
Under Linux ,if I want to pass pure string from PHP to C, how

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.