eclipse - Google Maps Android API V2 showing current location with marker(where am i in google android maps api v2) -


i beginner in android , developing android app displaying current location on google maps.but run application display message "unfortunately stopped" on emulator physical device. attaching code .plz have look. pls me ....i not able resolve this

thanks

mainactivity.java

package com.example.mapp;

import android.app.dialog; import android.location.location; import android.os.bundle; import android.support.v4.app.fragmentactivity; import android.view.menu; import android.widget.textview;  import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.googleplayservicesutil; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.googlemap.onmylocationchangelistener; import com.google.android.gms.maps.supportmapfragment; import com.google.android.gms.maps.model.latlng;  public class mainactivity extends fragmentactivity implements onmylocationchangelistener { googlemap googlemap;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         int status=googleplayservicesutil.isgoogleplayservicesavailable(getbasecontext());         if(status!=connectionresult.success)         {             int requestcode=10;             dialog dialog=googleplayservicesutil.geterrordialog(status,this, requestcode);             dialog.show();         }         else         {             supportmapfragment fm = ((supportmapfragment) getsupportfragmentmanager().findfragmentbyid(r.id.map));                     googlemap=fm.getmap();                     googlemap.setmylocationenabled(true);                     googlemap.setonmylocationchangelistener(this);         }     }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }  @override public void onmylocationchange(location location) {      textview tvlocation=(textview)findviewbyid(r.id.textview1);     double latitude=location.getlatitude();     double longitude=location.getlongitude();     latlng latlng=new latlng(latitude,longitude);     googlemap.movecamera(cameraupdatefactory.newlatlng(latlng));     googlemap.animatecamera(cameraupdatefactory.zoomto(15));     tvlocation.settext("latitude:"+latitude+",longitude:"+longitude); }   } 

androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.mapp"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="8"         android:targetsdkversion="17" />      <uses-permission android:name="android.permission.access_network_state" />  <permission android:name="com.example.mapp.permission.map_recieve" android:protectionlevel="signature"/>     <uses-permission android:name="com.example.mapp.permission.map_recieve"/>     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" />     <!-- external storage caching. -->     <uses-permission android:name="android.permission.write_external_storage" />      <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.access_fine_location" />     <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name="com.example.mapp.mainactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>         <meta-data             android:name="com.google.android.maps.v2.api_key"             android:value="my_api_key" />     </application>  </manifest> 

*activity_main.xml*

<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" >      <textview         android:id="@+id/textview1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"/>         <fragment          class="com.google.android.gms.maps.supportmapfragment"         android:id="@+id/map"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentbottom="true"         android:layout_alignparentleft="true"         android:layout_aligntop="@+id/textview1"         />  </relativelayout> 

add following code inside application tag

<meta-data         android:name="com.google.android.gms.version"         android:value="@integer/google_play_services_version" /> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -