android - calling a mapFragment in an activity -


i want use mapfragment in activity created map's xml file , java file , call in main activity getting error

java.lang.stackoverflowerror on line

view view = inflater.inflate(r.layout.fragment_map, container, false); 

06-29 11:14:26.264 23599-23599/com.sifast.appsocle e/androidruntime: fatal exception: main java.lang.stackoverflowerror @ android.content.res.assetmanager.getresourcevalue(assetmanager.java:201) @ android.content.res.resources.getvalue(resources.java:1022) @ android.content.res.resources.loadxmlresourceparser(resources.java:2131) @ android.content.res.resources.getlayout(resources.java:865) @ android.view.layoutinflater.inflate(layoutinflater.java:394) @ com.sifast.appsocle.mapfrag.oncreateview(mapfrag.java:69) @ android.support.v4.app.fragment.performcreateview(fragment.java:1974) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1036) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1230) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1332) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2288) @ android.support.v4.view.layoutinflatercompathc$factorywrapperhc.oncreateview(layoutinflatercompathc.java:44) @ android.view.layoutinflater$factorymerger.oncreateview(layoutinflater.java:168) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:675) @ android.view.layoutinflater.inflate(layoutinflater.java:466) @ android.view.layoutinflater.inflate(layoutinflater.java:396) @ com.sifast.appsocle.mapfrag.oncreateview(mapfrag.java:69) @ android.support.v4.app.fragment.performcreateview(fragment.java:1974) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1036) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1230) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1332) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2288) @ android.support.v4.view.layoutinflatercompathc$factorywrapperhc.oncreateview(layoutinflatercompathc.java:44) @ android.view.layoutinflater$factorymerger.oncreateview(layoutinflater.java:168) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:675) @ android.view.layoutinflater.inflate(layoutinflater.java:466) @ android.view.layoutinflater.inflate(layoutinflater.java:396) @ com.sifast.appsocle.mapfrag.oncreateview(mapfrag.java:69) @ android.support.v4.app.fragment.performcreateview(fragment.java:1974) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1036) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1230) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1332) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2288) @ android.support.v4.view.layoutinflatercompathc$factorywrapperhc.oncreateview(layoutinflatercompathc.java:44) @ android.view.layoutinflater$factorymerger.oncreateview(layoutinflater.java:168) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:675) @ android.view.layoutinflater.inflate(layoutinflater.java:466) @ android.view.layoutinflater.inflate(layoutinflater.java:396) @ com.sifast.appsocle.mapfrag.oncreateview(mapfrag.java:69) @ android.support.v4.app.fragment.performcreateview(fragment.java:1974) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1036) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1230) @ android.support.v4.app.fragmentmanagerimpl.addfragment(fragmentmanager.java:1332) @ android.support.v4.app.fragmentmanagerimpl.oncreateview(fragmentmanager.java:2288) @ android.support.v4.view.layoutinflatercompathc$factorywrapperhc.oncreateview(layoutinflatercompathc.java:44) @ android.view.layoutinflater$factorymerger.oncreateview(layoutinflater.java:168) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:675) @ android.view.layoutinflater.inflate(layoutinflater.java:466) @ android.view.layoutinflater.inflate(layoutinflater.java:396) @ com.sifast.appsocle.mapfrag.oncreateview(mapfrag.java:69) @ android.support.v4.app.fragment.performcreateview(fragment.java

here xml , java

 <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-au to" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/map" android:name="com.sifast.appsocle.mapfrag" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.sifast.appsocle.mapfrag" /> 

java code

public class mapfrag  extends  android.support.v4.app.fragment implements onmapreadycallback, locationlistener {   public static fragmentmanager fragmentmanager; private googlemap map; private locationmanager locationmanager; private boolean isgpsenabled, isnetworkenabled, isgpstrackingenabled; private string provider_info; private static string tag = mapsactivity.class.getname(); private location location; private double latitude; private double longitude; // minimum distance change updates in meters private static final long min_distance_change_for_updates = 10; // 10 meters  // minimum time between updates in milliseconds private static final long min_time_bw_updates = 1000 * 60 * 1; // 1 minute   public mapfrag() {     // required empty public constructor }    @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);    }  @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {      // inflate layout fragment     view view = inflater.inflate(r.layout.fragment_map, container, false);     getmylocation();     return view;  }   @override public void onlocationchanged(location location) {      //txtoutput.settext(location.tostring());     system.out.println(string.valueof(location.getlatitude()));     system.out.println(string.valueof(location.getlongitude()));       try {          map.clear();     } catch (exception e) {     }     latlng mypos = new latlng(location.getlatitude(), location.getlongitude());      //camera annimation     cameraposition campos = new cameraposition.builder().target(mypos)             .zoom(70)             .bearing(45)             .tilt(65)             .build();      cameraupdate camupd3 = cameraupdatefactory.newcameraposition(campos);   map.animatecamera(camupd3);     map.addmarker(new markeroptions().position(mypos).title("here !!"));      // mmap.movecamera(cameraupdatefactory.newlatlng(mypos));     //map.movecamera(cameraupdatefactory.newlatlng(mypos));   }  @override public void onmapready(googlemap googlemap) {     map= googlemap;       if (activitycompat.checkselfpermission(getactivity(), android.manifest.permission.access_fine_location) != packagemanager.permission_granted && activitycompat.checkselfpermission(getactivity(), manifest.permission.access_coarse_location) != packagemanager.permission_granted) {         // todo: consider calling         //    activitycompat#requestpermissions         // here request missing permissions, , overriding         //   public void onrequestpermissionsresult(int requestcode, string[] permissions,         //                                          int[] grantresults)         // handle case user grants permission. see documentation         // activitycompat#requestpermissions more details.         return;     }     map.setmylocationenabled(true);     locationmanager locationmanager = (locationmanager) getactivity().getsystemservice(getactivity().location_service);       return;  }  void getmylocation(){       // definition of location manager      locationmanager locmanager = (locationmanager) getactivity().getsystemservice(context.location_service);     //definition of listenner     locationlistener locationlistener = new locationlistener() {         // called when new location found network location provider.         public void onlocationchanged(location location) {             // setting camera of map positionate marker in current position             latlng mylaln = new latlng(location.getlatitude(), location.getlongitude());              cameraposition campos = new cameraposition.builder().target(mylaln)                     .zoom(15)                     .bearing(45)                     .tilt(70)                     .build();              cameraupdate camupd3 = cameraupdatefactory.newcameraposition(campos);              map.animatecamera(camupd3);              //  setting marker in current position              marker marker = map.addmarker(new markeroptions()                     .position(new latlng(location.getlatitude(), location.getlongitude()))                     .title("my position")                     .snippet("population: 776733"));           }       }; }} 

and how call in on create function

     mapfrag mymap = new mapfrag();         android.support.v4.app.fragmentmanager fragmentmanager=getsupportfragmentmanager();          android.support.v4.app.fragmenttransaction transaction = fragmentmanager.begintransaction();         transaction.add(r.id.myhomecontainer,mymap,"test");          transaction.commit(); 


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -