Android uses intent to get null
An error is reported when I pass the token through intent. It is a null pointer. I use the getMap method to transfer the value. The Code is as follows:
public void getMap(View view){ Intent i = new Intent(this, BreweryYourTopBeers.class); Log.d(map , e.beerBreweryId); i.putExtra(breweryID, e.beerBreweryId); i.setClass(this, BreweryMap.class); startActivity(i); }
From my logs, we can see that e. beerBreweryId does have a value before passing the value. I will get the value to be changed in the following code.
Public class BreweryMap extends ActionbarMenu {BeerData e; String beerID; GoogleMap map; // obtain beer details from bundle protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_brewerymap); // get brewery data // get beer data Intent intent = getIntent (); Bundle extras = intent. getExtras (); String breweryID = extras. getString (brewreyID); map = (MapFragment) getFragmentManager (). findFragmentById (R. id. map). getMap (); String url = http://api.brewerydb.com/v2/brewery/+ breweryID +? Key = myKey & format = json & withLocations = y; Log. d (map, url); new myAsyncTask(this,map).exe cute (url );}}
Every time I get the value, it is NULL. I don't know why.
Solution
A write error occurred.
Set
String breweryID = extras. getString (brewreyID );
Change
String breweryID = extras. getString (breweryID );