Question

Here is the code in the first activity:

Bundle UserEntries = new Bundle();
UserEntries.putString("Venue_Name", VenueName);
UserEntries.putString("Event_Name", EventName);
UserEntries.putString("Category", Category);
UserEntries.putString("Region", Region);
Intent openGetData = new Intent(SearchDatabase.this, GetData.class);
openGetData.putExtra("UserEntries", UserEntries);
startActivity(openGetData);

And this is the code in the activty opened:

Intent i = getIntent();
    Bundle Parameters = i.getExtras();
    url = "http://192.168.1.74/android_connect/get_venues.php";
    VenueName = Parameters.getString("Venue_Name");
    EventName = Parameters.getString("Event_Name");
    Category = Parameters.getString("Category");
    Region = Parameters.getString("Region");
    if(VenueName != null){
        phpExtension = ("?Venue_Name=" + VenueName);
    }
    url = (url + phpExtension);

However Venue_Name returns null, i have tested the code and in the first activity it is not null and in the second activity the bundle Parameters is not null, however the string Venue_Name within the bundle in the second activity is. Anyone have any ideas where im going wrong?

Thanks in advance

Was it helpful?

Solution 2

Do it like this in the first Activity-

Intent openGetData = new Intent(SearchDatabase.this, GetData.class);
openGetData.putExtra("Venue_Name", VenueName);
openGetData.putExtra("Event_Name", EventName);
openGetData.putExtra("Category", Category);
openGetData.putExtra("Region", Region);
startActivity(openGetData);

OTHER TIPS

The problem is that you're only passing your Bundle object to your extras, not the String datas.

You need to retrieve first the bundle you passed, and then you will be able to get the data added in the bundle:

Bundle Parameters = i.getBundleExtra("UserEntries");


Another way would be to simply pass direclty the Strings to your intent using putExtra(String name, int value) and get rid of this UserEntries object in your first activity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top