Android obtains null via intent value

Source: Internet
Author: User

I am passing through the intent to get delivery of the error, null pointer, I am the Getmap method to pass 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);    }


I can see from my log that E.beerbreweryid does have a value before the value is passed, and I get the change in the code below

public class Brewerymap extends Actionbarmenu {    beerdata e;     String Beerid;     GoogleMap map;  get beer details from bundles     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). Execute (URL);}}


Every time I get the value is NULL, do not know what the reason.

Processing methods

One line has been written wrong.
Put
String Breweryid = extras.getstring ("Brewreyid");
Into
String Breweryid = extras.getstring ("Breweryid");


Original address: http://www.itmmd.com/201411/134.html
This article by Meng Meng's IT person to organize the release, reprint must indicate the source.

Android obtains null via intent value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.