Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>it only lag if you press the back button?</p> <p>if thats the problem try to block the back button or make it exit the app try this code:</p> <pre><code> @Override public void onBackPressed(){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("You wanna leave the aplication?").setPositiveButton("Yes", dialogClickListener) .setNegativeButton("No", dialogClickListener).show(); } </code></pre> <p>or try this code its a way to put a map fragment inside another fragment (nested Map Fragment) it worked for me a weeks ago:</p> <p>Java Class:</p> <pre><code>public class Yourfragment extends Fragment { private MapView mMapView; private GoogleMap mMap; private Bundle mBundle; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View inflatedView = inflater.inflate(R.layout.map_fragment, container, false); try { MapsInitializer.initialize(getActivity()); } catch (GooglePlayServicesNotAvailableException e) { // TODO handle this situation } mMapView = (MapView) inflatedView.findViewById(R.id.map); mMapView.onCreate(mBundle); setUpMapIfNeeded(inflatedView); return inflatedView; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBundle = savedInstanceState; } private void setUpMapIfNeeded(View inflatedView) { if (mMap == null) { mMap = ((MapView) inflatedView.findViewById(R.id.map)).getMap(); if (mMap != null) { setUpMap(); } } } private void setUpMap() { mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")); } @Override public void onResume() { super.onResume(); mMapView.onResume(); } @Override public void onPause() { super.onPause(); mMapView.onPause(); } @Override public void onDestroy() { mMapView.onDestroy(); super.onDestroy(); } } </code></pre> <p>XML:</p> <pre><code>&lt;com.google.android.gms.maps.MapView android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; </code></pre> <p>put this code on post execute:</p> <pre><code>View inflatedView = inflater.inflate(R.layout.map_fragment, container, false); try { MapsInitializer.initialize(getActivity()); } catch (GooglePlayServicesNotAvailableException e) { // TODO handle this situation } mMapView = (MapView) inflatedView.findViewById(R.id.map); mMapView.onCreate(mBundle); setUpMapIfNeeded(inflatedView); return inflatedView; </code></pre> <p>and call the assynctask on oncreateview</p> <p>Try this:</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Call assyncTask } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBundle = savedInstanceState; } private void setUpMapIfNeeded(View inflatedView) { if (mMap == null) { mMap = ((MapView) inflatedView.findViewById(R.id.map)).getMap(); if (mMap != null) { setUpMap(); } } } private void setUpMap() { mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")); } @Override public void onResume() { super.onResume(); mMapView.onResume(); } @Override public void onPause() { super.onPause(); mMapView.onPause(); } @Override public void onDestroy() { mMapView.onDestroy(); super.onDestroy(); } private class GetFlightsTask extends AsyncTask&lt;Double, Void, String&gt; { @Override protected void onPreExecute() { super.onPreExecute(); // if I remove the next line, everything gets fixed loadingFlightsSpinner.show(); } @Override protected String doInBackground(Double... params) { // some pretty long remote API call // (loading a JSON file from http://some.website.com/flights?...) // works fine String flightsJSON = loadJSON("flights?flyFrom=CZ&amp;to=..."); } @Override protected void onPostExecute(String flightsJSON) { super.onPostExecute(flightsJSON); loadingFlightsSpinner.dismiss(); // here I do stuff with the JSON and then replace the fragment dohardwork() } public view dohardwork(){ View inflatedView = inflater.inflate(R.layout.map_fragment, container, false); try { MapsInitializer.initialize(getActivity()); } catch (GooglePlayServicesNotAvailableException e) { // TODO handle this situation } mMapView = (MapView) inflatedView.findViewById(R.id.map); mMapView.onCreate(mBundle); setUpMapIfNeeded(inflatedView); return inflatedView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload