i have implemented android google maps v2 in application , working fine on of devices(galaxy ace plus, galaxy 7inch tab, sony xperia z) tested. it's not working on htc desire. have cross verified google play services installed in device. goggled lot find solution. below implementation.
public class mainactivity extends fragmentactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); supportmapfragment fragment = new supportmapfragment(); getsupportfragmentmanager().begintransaction() .add(android.r.id.content, fragment).commit(); } }
below activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/the_map" android:name="com.google.android.gms.maps.supportmapfragment" android:layout_width="match_parent" android:layout_height="match_parent" map:cameratilt="45" map:camerazoom="2" />
and here manifest file.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.raj.googlemapsv2test" android:versioncode="1" android:versionname="1.0" > <permission android:name="com.raj.googlemapsv2test.permission.maps_receive" android:protectionlevel="signature" /> <uses-permission android:name="com.raj.googlemapsv2test.permission.maps_receive" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.access_coarse_location" /> <uses-permission android:name="android.permission.access_fine_location" /> <uses-feature android:glesversion="0x00020000" android:required="true" /> <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.maps.v2.api_key" android:value="aizasydd6bvuvktk2uzolpojdebtlh5xbydhy6e" /> <activity android:name="com.raj.googlemapsv2test.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> </application> </manifest>
when check logs showing following error lines.
not find class 'maps.i.k', referenced method maps.z.ag.a failed load map. not contact google servers. failed load map. not contact google servers.
and small doubt updated goggle maps app in device , after it's working. wants show alert user update when kind of issue found of devices. unable know how check this. can 1 suggest way find whether goggle maps app , android goggle play services in device of supportive version android goggle maps v2 or not.
any solution appreciated.
you can add code onresume method. checks if user has updated version of google play services, , if not, popup redirecting him google play shown.
@override protected void onresume() { super.onresume(); int errorcode = googleplayservicesutil.isgoogleplayservicesavailable(this); if(errorcode != connectionresult.success && googleplayservicesutil.isuserrecoverableerror(errorcode)){ dialog d = googleplayservicesutil.geterrordialog(errorcode, this, 0, new oncancellistener() { @override public void oncancel(dialoginterface dialog) { //as application heavy use of maps, if user cancels dialog, finish fragmentactivity mainfragmentactivity.this.finish(); } }); d.show(); } }
hope helps, cheers!
Comments
Post a Comment