0

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

James Roberts
  • 195
  • 1
  • 4
  • 13
  • I recommend you to start variables with a lowercase letter as it's standard. Uppercase is for classnames. – Endzeit Feb 21 '14 at 17:40

2 Answers2

1

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.
Alexis C.
  • 91,686
  • 21
  • 171
  • 177
0

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);
amit singh
  • 1,407
  • 2
  • 16
  • 25