android maps view blank -


i following steps in google can't see map in fragment. bellow code. if guys please me?

i added google-play-services_lib project. testing in real device. using google apis

mainfest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"     package="com.example.mymaps"     android:versioncode="1"     android:versionname="1.0" >      <uses-sdk         android:minsdkversion="12"         android:targetsdkversion="17" />      <uses-feature         android:glesversion="0x00020000"         android:required="true"/>      <permission         android:name="com.example.mymap.permission.maps_receive"         android:protectionlevel="signature" />      <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="com.example.mymap.permission.maps_receive" />     <uses-permission android:name="android.permission.access_coarse_location" />     <uses-permission android:name="android.permission.access_fine_location" />     <uses-permission android:name="android.permission.access_network_state" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_wifi_state" />      <application         android:allowbackup="true"         android:icon="@drawable/ic_launcher"         android:label="@string/app_name"         android:theme="@style/apptheme" >         <activity             android:name="com.example.mymaps.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 key" />         <uses-library         android:name="com.google.android.maps"         android:required="true" />      </application>  </manifest> 

ui 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"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     tools:context=".mainactivity" >      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="@string/hello_world" />      <fragment          android:id="@+id/the_map"     android:layout_width="match_parent"     android:layout_height="match_parent"     class="com.google.android.gms.maps.mapfragment"      />  </relativelayout> 

mainactivity:

package com.example.mymaps;  import android.app.activity; import android.os.bundle; import android.view.menu;          public class mainactivity extends activity {         @override         protected void oncreate(bundle savedinstancestate) {             super.oncreate(savedinstancestate);             try {                     setcontentview(r.layout.activity_main);                          } catch (exception e) {                  system.out.print(e);             }         }          @override         public boolean oncreateoptionsmenu(menu menu) {             // inflate menu; adds items action bar if present.             getmenuinflater().inflate(r.menu.main, menu);             return true;         }     } 

dec variable global private googlemap googlemap;

extends fragmentactivity not activity

after setcontentview add code

fragmentmanager fragmentmanager = getsupportfragmentmanager();     supportmapfragment mapfragment = (supportmapfragment) fragmentmanager             .findfragmentbyid(r.id.map);     googlemap = mapfragment.getmap();     googlemap.getuisettings().setcompassenabled(true);     googlemap.getuisettings().setzoomcontrolsenabled(true);     googlemap.getuisettings().setmylocationbuttonenabled(true);     googlemap.setmylocationenabled(true);     googlemap.getuisettings().setmylocationbuttonenabled(true);     googlemap.getuisettings().setrotategesturesenabled(true); 

in xml

 <fragment     android:id="@+id/map"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:name="com.google.android.gms.maps.supportmapfragment" /> 

if generate googlemap api key currect pakage name work


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -