android - start navigating to position which is stored in database -


i have application getting latitude , longitude coordinates.

i want , when press button start navigating position .

now , storing latitude , longitude in database.

so , want extract location first.when press button navigate open alertdialog , in 'yes' do:

public void navigation(final view v){         alertdialog.builder alt_bld = new alertdialog.builder(this);         alt_bld.setmessage("do want navigate saved position?")                 .setcancelable(false)                 .setpositivebutton("navigate",                         new dialoginterface.onclicklistener() {                             public void onclick(dialoginterface dialog,                                     int id) {                          // action 'yes' button                          string query = "select latitude,longitude memories ";                         cursor c1 = sqlhandler.selectquery(query);                          if (c1 != null && c1.getcount() != 0) {                             if (c1.movetofirst()) {                                 {                         string mylatitude=c1.getstring(c1.getcolumnindex("latitude"));         string mylongitude=c1.getstring(c1.getcolumnindex("longitude"));          double lat=double.parsedouble(mylatitude);         double lon=double.parsedouble(mylongitude);                                        } while (c1.movetonext());                                 }                             }                              c1.close();               intent intent = new intent(android.content.intent.action_view,                      uri.parse("http://maps.google.com/maps?saddr=" +                      gps.getlocation().getlatitude() + "," +                      gps.getlocation().getlongitude() + "&daddr=" + mylatitude + "," + mylongitude ));                     startactivity(intent);                               }                         })                 .setnegativebutton("cancel",                         new dialoginterface.onclicklistener() {                             public void onclick(dialoginterface dialog,                                     int id) {                                 // action 'no' button                                 dialog.cancel();                             }                         });         alertdialog alert = alt_bld.create();         // title alertdialog         alert.settitle("navigation");         alert.show();   } 

i have location stored (lat , lon) , want start navigating position. how can that?

thanks!

---------------------update-------------------------------------

if sth like:

    string mylat=""; string mylon="";   @override protected void oncreate(bundle savedinstancestate) { ... ... public void navigation(final view v){ .... string mylatitude=c1.getstring(c1.getcolumnindex("latitude")); string mylongitude=c1.getstring(c1.getcolumnindex("longitude"));   mylat=mylatitude;//stored coordinates database  mylon=mylongitude;  string f="45.08" //current location (start points) string s="23.3";  intent intent = new intent(android.content.intent.action_view,  uri.parse("http://maps.google.com/maps?saddr=" +  f + "," +  s + "&daddr=" + mylat + "," + mylon )); startactivity(intent); 

the intent starts , in map application start points "f" , "s" defined above destination points 0.0 , 0.0 ;

so , have 2 problems:

1) how put destination points stored locations (mylatitude ,mylongitude (which copy mylat,mylon)

2) how current location (initial points) because gps class doesn't work on that.

in example below impllocationservice class/service within application providing latitude , longitude coordinates of current location within device. location class similar android's offering different , providing destination latitude , longitude coordinates. if pull these values database, approach below same.

        intent intent = new intent(android.content.intent.action_view,                 uri.parse("http://maps.google.com/maps?saddr=" +                 impllocationservice.getcurrentlocation().getlatitude() + "," +                 impllocationservice.getcurrentlocation().getlongitude() + "&daddr=" +                 location.getpoint().latitude + "," + location.getpoint().longitude));         startactivity(intent); 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -