android - Intents and google maps api v2 -


i know question silly, i'm bit confused intents.from code below want separate in 2 classes showmap , locationmap.how can this??the fist contain map(fragmentactivity), call second class in want find user's current location , return marker map(first activity).thanks in advance!here class want separate:

public class locationmap extends fragmentactivity implements locationlistener{  private googlemap googlemap; private latlng latlng; textview tvlocation; markeroptions markeroptions;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.location_maps);       // getting google play availability status                int status = googleplayservicesutil.isgoogleplayservicesavailable(getbasecontext());      // showing status     if(status!=connectionresult.success){ // google play services not available          int requestcode = 10;         dialog dialog = googleplayservicesutil.geterrordialog(status, this, requestcode);         dialog.show();      }else { // google play services available          // getting reference supportmapfragment of activity_main.xml         supportmapfragment fm = (supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map);          // getting googlemap object fragment         googlemap = fm.getmap();         //setting zoomin-zoomout bar in screen         googlemap.getuisettings().setzoomcontrolsenabled(true);          // enabling mylocation layer of google map         googlemap.setmylocationenabled(true);          //googlemap.setmaptype(googlemap.map_type_normal);         // getting locationmanager object system service location_service         locationmanager locationmanager = (locationmanager) getsystemservice(location_service);          // creating criteria object retrieve provider         criteria criteria = new criteria();          // getting name of best provider         string provider = locationmanager.getbestprovider(criteria, true);          // getting current location         location location = locationmanager.getlastknownlocation(provider);          if(location!=null){             onlocationchanged(location);             new reversegeocodingtask(getbasecontext()).execute(latlng);                        }         locationmanager.requestlocationupdates(provider, 20000, 0, this);     }   }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.location_maps, menu);      // associate searchable configuration searchview     searchmanager searchmanager = (searchmanager) getsystemservice(context.search_service);     searchview searchview = (searchview) menu.finditem(r.id.action_search)             .getactionview();     searchview.setsearchableinfo(searchmanager             .getsearchableinfo(getcomponentname()));      return super.oncreateoptionsmenu(menu);   }   @override public boolean onoptionsitemselected(menuitem item) {     // take appropriate action each action item click     switch (item.getitemid()) {     case r.id.action_search:          return true;       case r.id.menu_settings:         // refresh         return true;      default:         return super.onoptionsitemselected(item);     } }      @override public void onlocationchanged(location location) {        googlemap.clear();       // getting latitude of current location     double latitude = location.getlatitude();      // getting longitude of current location     double longitude = location.getlongitude();      // creating latlng object current location      latlng = new latlng(latitude, longitude);          // showing current location in google map       googlemap.movecamera(cameraupdatefactory.newlatlng(latlng));      // zoom in google map     googlemap.animatecamera(cameraupdatefactory.zoomto(10));      markeroptions = new markeroptions();      // setting position marker      markeroptions.position(latlng);     // executing reversegeocodingtask address    new reversegeocodingtask(getbasecontext()).execute(latlng);       }   @override public void onproviderdisabled(string provider) {     // todo auto-generated method stub            toast.maketext( getapplicationcontext(),     "gps disabled",toast.length_short ).show();     }   @override public void onproviderenabled(string provider) {     // todo auto-generated method stub }  @override public void onstatuschanged(string provider, int status, bundle extras) {     // todo auto-generated method stub }    private class reversegeocodingtask extends asynctask<latlng, void, string>{     context mcontext;      public reversegeocodingtask(context context){         super();         mcontext = context;     }      // finding address using reverse geocoding     @override     protected string doinbackground(latlng... params) {         geocoder geocoder = new geocoder(mcontext);         double latitude = params[0].latitude;         double longitude = params[0].longitude;          list<address> addresses = null;         string addresstext="";          try {             addresses = geocoder.getfromlocation(latitude, longitude,1);         } catch (ioexception e) {             e.printstacktrace();         }          if(addresses != null && addresses.size() > 0 ){             address address = addresses.get(0);              addresstext = string.format("%s, %s, %s",             address.getmaxaddresslineindex() > 0 ? address.getaddressline(0) : "",             address.getlocality(),             address.getcountryname());         }          return addresstext;     }      @override     protected void onpostexecute(string addresstext) {         textview tvlocation = (textview) findviewbyid(r.id.tv_location);         log.v ("4",addresstext );         tvlocation.settext(addresstext);           // setting title marker.         markeroptions.title(addresstext);                googlemap.addmarker(markeroptions);       } } 

} }


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -