android - How to display map using fragment -


    mainactivity.java       import com.google.android.gms.maps.googlemap;     import com.google.android.gms.maps.mapfragment;     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 android.os.bundle;     import android.annotation.targetapi;     import android.app.activity;       public class mainactivity extends activity      {      static final latlng latlng = new latlng(13 , 80);     private googlemap googlemap;     @override     protected void oncreate(bundle savedinstancestate)      {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     try {      if (googlemap == null) {     googlemap = ((mapfragment) getfragmentmanager().findfragmentbyid(r.id.map)).getmap();     }     googlemap.setmaptype(googlemap.map_type_hybrid);     marker mar = googlemap.addmarker(new markeroptions().     position(latlng).title("google map"));      } catch (exception e) {     e.printstacktrace();     }      }      }       activity_main.xml      <?xml version="1.0" encoding="utf-8"?>     <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <fragment     android:id="@+id/map"     android:name="com.google.android.gms.maps.mapfragment"     android:layout_width="match_parent"     android:layout_height="match_parent"/>      </relativelayout>         manifest.xml      <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="15" />      <permission     android:name="com.example.mapp.permission.maps_receive"     android:protectionlevel="signature" />      <uses-permission android:name="com.example.mapp.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="com.google.android.providers.gsf.permission.read_gservices" />     <uses-permission android:name="android.permission.write_external_storage" />      <uses-feature     android:glesversion="0x00020000"     android:required="true" />      <application     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity     android:name=".mainactivity"     android:label="@string/title_activity_main" >     <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="aizasydxylsdkao4z45gwjrke2qinmqofeqcduy" />     </application>      </manifest> 

am new android .i dont know how display map using fragment.this code.i dont map.my program unfortunately stopped.and got error in logcat:no activity found handle.can me please

you need activate google map api v2 google developer console, there need generate map api key, need give key map.

additionally, need declare classes in android manifect file, after can see map. process , must need follow it.

just visit sites :https://developers.google.com/maps/documentation/android/start


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -