android - Getting gps not working -


can explain me why code not working? tried gps easy posible. debugger didn t find error when run it, doesn t work. can gps enabled , gps disabled msges never gps latitude , longtitude..

here s code:

public class getgps extends appcompatactivity {  double longtitude; double latitude;   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_getgps);     locationmanager mlocmanager = (locationmanager)getsystemservice(context.location_service);     locationlistener mloclistener = new mylocationlistener();     mlocmanager.requestlocationupdates(locationmanager.gps_provider, 5000, 10, mloclistener);   }   public class mylocationlistener implements locationlistener {     @override     public void onlocationchanged(location loc)     {          latitude = loc.getlatitude();         longtitude = loc.getlongitude();         string text = "my current location is: " +                 "latitude = " + latitude +                 "longitude = " + longtitude;         toast.maketext( getapplicationcontext(),                 text,                 toast.length_short).show();      }     @override     public void onproviderdisabled(string provider)     {         toast.maketext( getapplicationcontext(),                 "gps disabled",                 toast.length_short ).show();      }     @override     public void onproviderenabled(string provider)     {            toast.maketext( getapplicationcontext(),                 "gps enabled",                 toast.length_short).show();      }     @override     public void onstatuschanged(string provider, int status, bundle extras)     {         toast.maketext( getapplicationcontext(), + latitude +" ",         toast.length_short).show();      }  }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_getgps, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();      //noinspection simplifiableifstatement     if (id == r.id.action_settings) {         return true;     }      return super.onoptionsitemselected(item); } } 

thanks ideas. ^_-

as mentioned in comment above, please make sure test application under open sky atleast once. gps gets fixed , gps data.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -