View Single Post
  #6 (permalink)  
Old September 26th, 2014, 06:24 AM
wolfenr wolfenr is offline
Authorized User
Points: 65, Level: 1
Points: 65, Level: 1 Points: 65, Level: 1 Points: 65, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Posts: 15
Thanks: 2
Thanked 1 Time in 1 Post
Default Source code for Chapter 7

Well thanks for the updated chapter which I have (eventually) got working fine. I say eventually as I spent a day or so fiddling with some obscure bug in my google-play-services.lib which I won't go into.

However, what would have significantly helped the debug process would have been to have different downloadable source codes for each part of the chapter i.e. Google Maps 7.1 through to Google Maps 7.7. The reason I'm asking for this is that the at section 7.1 the code is relatively straightforward but has become much more complex with the supplied source code as it encompasses all the working sections of the chapter.

So if others are experiencing the same issue here is my source code for Section 7.1 which is where you're able to check that you've got your basic API, google-play-services.lib etc. etc. all set up OK...

activity_main.xml
Code:
<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">

    <fragment
        android:id="@+id/map"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        class="com.google.android.gms.maps.MapFragment"
        android:clickable="true" />

</RelativeLayout>
MainActivity.java
Code:
package com.example.googlemaps;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

	}
}
GoogleMapsManifest
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googlemaps"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <permission
        android:name="com.example.googlemaps.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.googlemaps.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" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.googlemaps.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.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="Your API key here...." />
    </application>

</manifest>
Reply With Quote