android - Launching map Activity using Intents not working -


i'm trying launch maps show particular places when button pressed, thought use intents open map see google sign in bottom left hand corner , beige screen.

i'm new i'm not sure i'm doing wrong?

this activity launch maps:

public class showmaps extends actionbaractivity {  button sot; button sta; button lic; button shr;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_show_maps);     sot = (button) findviewbyid(r.id.sot) ;     sta = (button) findviewbyid(r.id.sta);     lic = (button) findviewbyid(r.id.lic);     shr = (button) findviewbyid(r.id.shr);      sot.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              intent = new intent(showmaps.this, sot.class);              startactivity(i);          }     });     sta.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              intent = new intent(showmaps.this, sta.class);              startactivity(i);          }     });     lic.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              intent = new intent(showmaps.this, lic.class);              startactivity(i);          }     });     shr.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              intent = new intent(showmaps.this, shr.class);              startactivity(i);          }     }); }   @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.menu_show_maps, 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); } } 

here 1 of map fragments code same in 4 lat&long have changed:

public class sot extends fragmentactivity {  private googlemap mmap; // might null if google play services apk not available.  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_sot);     setupmapifneeded(); }  @override protected void onresume() {     super.onresume();     setupmapifneeded(); }  /**  * sets map if possible (i.e., google play services apk correctly  * installed) , map has not been instantiated.. ensure ever  * call {@link #setupmap()} once when {@link #mmap} not null.  * <p/>  * if isn't installed {@link supportmapfragment} (and  * {@link com.google.android.gms.maps.mapview mapview}) show prompt user  * install/update google play services apk on device.  * <p/>  * user can return fragmentactivity after following prompt , correctly  * installing/updating/enabling google play services. since fragmentactivity may not  * have been destroyed during process (it  * stopped or paused), {@link #oncreate(bundle)} may not called again should call  * method in {@link #onresume()} guarantee called.  */ private void setupmapifneeded() {     // null check confirm have not instantiated map.     if (mmap == null) {         // try obtain map supportmapfragment.         mmap = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.sotmap))                 .getmap();         // check if successful in obtaining map.         if (mmap != null) {             setupmap();         }     } }  /**  * can add markers or lines, add listeners or move camera. in case,  * add marker near africa.  * <p/>  * should called once , when sure {@link #mmap} not null.  */ private void setupmap() {     mmap.addmarker(new markeroptions().position(new latlng(53.009066, -2.176138)).title("marker")); } } 

see here: open google maps through intent specific location in android

so yes there way open maps using intents. involves using uris.

the code is:

string uri = string.format(locale.english, "geo:%f,%f", latitude, longitude); intent intent = new intent(intent.action_view, uri.parse(uri)); startactivity(intent); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -