0
iは、MapViewのを見る私の断片に表示しようと、私はGoogleのコンソールdevoloperでキーを作成して、フラグメントビューでは動作しません。私の世代私のPCとすべてのathersの手順でキーが、私はalwys wを取得グレンscren、私はそれをどのように修正することができます。グーグルマップは
コード:
ホームfragment.java
package com.malek.sos.sosdepanage;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.model.LatLng;
/**
* A simple {@link Fragment} subclass.
*/
public class HomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
public HomeFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_home, container, false);
mapView = (MapView) v.findViewById(R.id.mapview);
mapView.onCreate(savedInstanceState);
map = mapView.getMap();
/* map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
*/
// Needs to call MapsInitializer before doing any CameraUpdateFactory calls
MapsInitializer.initialize(this.getActivity());
// Updates the location and zoom of the MapView
/* CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
map.animateCamera(cameraUpdate);*/
return v;
}
}
断片ホームレイアウト
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
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:background="@color/white"
tools:context="com.malek.sos.sosdepanage.HomeFragment"
android:name="com.google.android.gms.maps.SupportMapFragment" >
<!-- TODO: Update blank fragment layout -->
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
のmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.malek.sos.sosdepanage">
<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.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<permission
android:name="com.example.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.permission.MAPS_RECEIVE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyC7esM0vElp3uNvgj6AgrWjuyQmAG_G1ac"/>
<activity android:name=".MainActivity" android:theme="@style/AppTheme"/>
<activity android:name=".LoginActivity" android:theme="@style/AppTheme"/>
<activity android:name=".HomeActivity" android:theme="@style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
は、私は常にモニターでこれを取得 'D/OpenGLRenderer:prepareDirty(0.00、0.00、720.00、1280.00)不透明な1 <0x6005ca70> 5月21日02:15:44.628 28179から28179/com.malek.sos.sosdepanage D/OpenGLRenderer:仕上げ<0x6005ca70> ' –