Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Current Location with Android Google Map API(v2) but getting Unfortunately application has stopped error
    primarykey
    data
    text
    <p>Here is Main Activity.java code : </p> <pre><code>package com.example.vd; import android.app.Activity; import android.location.Criteria; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.view.Menu; import android.support.v4.app.FragmentActivity; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapFragment; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap.OnMyLocationChangeListener; public class MainActivity extends FragmentActivity implements LocationListener { GoogleMap googleMap; LatLng myPosition; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SupportMapFragment fm=(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map1); googleMap=fm.getMap(); googleMap.setMyLocationEnabled(true); LocationManager locationManager=(LocationManager)getSystemService(LOCATION_SERVICE); Criteria criteria=new Criteria(); String provider =locationManager.getBestProvider(criteria, true); Location location=locationManager.getLastKnownLocation(provider); if(location!=null){ double latitude =location.getLatitude(); double longitude=location.getLongitude(); LatLng latlng=new LatLng(latitude, longitude); myPosition=new LatLng(latitude, longitude); googleMap.addMarker(new MarkerOptions().position(myPosition).title("Here")); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub } @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>}</p> <p>here is activity_main.xml code : </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" &gt; &lt;fragment android:id="@+id/map1" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/&gt; &lt;/RelativeLayout&gt; </code></pre> <p>And here is AndroidManifest.xml code :</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.example.vd" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="11" android:targetSdkVersion="14" /&gt; &lt;uses-feature android:glEsVersion="0x00020000" android:required="true"/&gt; &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; &lt;uses-permission android:name="com.example.vd.permission.MAPS_RECEIVE"/&gt; &lt;permission android:name="com.example.vd.permission.MAPS_RECEIVE" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.vd.MainActivity" android:label="@string/app_name" &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;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyB5pN0xyJTRLVOAX3scagfb58b0bB0TBwg"/&gt; &lt;/application&gt; </code></pre> <p></p> <p>And I'm using Android 4.2.2 and using library <code>google-play-services_lib</code> I've already search on the Internet and try to fix it for many many times but I still getting this error : Unfortunately application has stopped error.</p>
    singulars
    1. This table or related slice is empty.
    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