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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:11:23+00:00 2026-05-28T03:11:23+00:00

This has been asked once before but that didn’t work for me at all.

  • 0

This has been asked once before but that didn’t work for me at all. So I thought I’ll just ask again.

I have a JSONarray that I want to pass to my second activity using an intent.

This is a part of my code which connects to a mysql database and puts data about a user in a JSONarray. This all works so far.

try{
    BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
    sb = new StringBuilder();
    sb.append(reader.readLine() + "\n");

    String line="0";
    while ((line = reader.readLine()) != null) {
        sb.append(line + "\n");
    }
    is.close();
    result=sb.toString();

    }catch(Exception e){
        Log.e("log_tag", "Error converting result "+e.toString());
    }

String ct_user;
String ct_pass;

Intent personal = new Intent(Home.this, Loggedin.class);

try{
    jArray = new JSONArray(result);
    JSONObject json_data=null;
    json_data = jArray.getJSONObject(0);
    ct_user = json_data.getString("user");
    ct_pass = json_data.getString("pass");


    if (passwordstring.equals(ct_pass)){

        Bundle b = new Bundle();                
        b.putString("userdata",json_data.toString());
        personal.putExtras(b);

        startActivity(personal);
            }
    }

I’d like to send my complete JSONarray through an intent to my second activity (Loggedin). So that I can display for example ct_email = json_data.getString(“email”); which is another value in the array that the first activity gets from mysql.

This was the other question about this subject:
passing jsonarray from 1 activity to another

That solution didn’t work for me because in the second activity errors kept saying it couldn’t convert bundle to intent, I tried everything I could think of.

Intent b = getIntent().getExtras();
String userdata=b.getString("userdata");

Thanks


EDIT

Thanks for the quick answers guys. I’m new to Stackoverflow so pardon my mistakes regarding code markings etc. I try to do it all properly.

But it’s still not working for me. This is part of my second activity:

public class Loggedin extends Activity {


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.loggedin);

    myfunction();

}

public void myfunction(){

    Bundle b = getIntent().getExtras();
    String userdataArray = b.getString("userdata");

    String ct_email;
    ct_email = userdataArray.getString("email");


}

}

The error is the “method getString(String) is undefined for the type String”.
I must be doing something stupid.

  • 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-28T03:11:24+00:00Added an answer on May 28, 2026 at 3:11 am

    getExtras() returns Bundle, not Intent. Change your code like this and try.

    Bundle b = getIntent().getExtras(); 
    String userdata=b.getString("userdata"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has been asked before (question no. 308581) , but that particular question and
This is probably a question that has been asked before, but I couldn't find
This question has been asked more than once before, but I have not found
This has been driving me nuts. I hope it's not been asked before but
I'm sure this has been asked before, but I can't find it. What are
Forgive me if this has been asked before; I did a search but couldn't
I know this has been asked before, but I've found a different way to
Forgive me if this has been asked before, but I assure you I've scoured
I know this has been asked different ways several times, but I'm just not
I know this has been asked thousands of times but I just can't find

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.