Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid GPS maps
    primarykey
    data
    text
    <p>I want to make GPS app and I'm starting with this code which is copy paste from another tutorial. But when I test the app it blank space and the map doesn't appear! Can any one help please??!! </p> <p>Here is the code </p> <pre><code> package com.manita.mapuse; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.KeyEvent; import android.widget.Toast; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapController; import com.google.android.maps.MapView; public class MapuseActivity extends MapActivity implements LocationListener { private MapView mapView = null; private LocationManager lm = null; private double lat = 0; private double lng = 0; private MapController mc = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) this.findViewById(R.id.mapView); mapView.setBuiltInZoomControls(true); lm = (LocationManager) this.getSystemService(LOCATION_SERVICE); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000, 0, this); mc = mapView.getController(); mc.setZoom(12); } @Override protected boolean isRouteDisplayed() { return false; } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_S) { mapView.setSatellite(!mapView.isSatellite()); return true; } return super.onKeyDown(keyCode, event); } @Override public void onLocationChanged(Location location) { lat = location.getLatitude(); lng = location.getLongitude(); Toast.makeText(getBaseContext(), "Location change to : Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_SHORT).show(); GeoPoint p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6)); mc.animateTo(p); mc.setCenter(p); } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @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 } } </code></pre> <p>Here is the manifest.xml </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.manita.mapuse" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;uses-library android:name="com.google.android.maps" /&gt; &lt;activity android:label="@string/app_name" android:name=".MapuseActivity" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_GPS" /&gt; &lt;uses-permission android:name="android.permission.LOCATION" /&gt; &lt;/manifest&gt; </code></pre> <p>and this is my MainActivity.xml </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mainlayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;com.google.android.maps.MapView android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="@string/mapKey" /&gt; &lt;LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Thank you.</p>
    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.
 

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