这两天都没什么任务,做个小应用热热手

下面是写的第一个Google Map 应用

要使用Google Map服务的话,我们需要一个API key。我们可以 通过如下方式获取API key:

1) 找到USER_HOME\Local Settings\Application Data\Android目录下的debug.keystore文件。
2) 使用keytool工具来生成认证信息(MD5),使用如下命令行:
keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass

android -keypass android
3) 打开 ‘Sign Up for the Android Maps API‘页面,输入之前生成的认证信息(MD5) 后将获取到你的API key。
4) 替换上面AndroidManifest.xml配置文件中“API_Key_String”为你刚才获取的API key

源代码:

1:Manifest xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.android.MapSample2"

android:versionCode="1"

android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="com.google.android.maps" />

<activity android:name=".MapSample2"

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>

<- 就是下面这几行搞得怎么地图没有显出来,原来写错位置了(原来在application里面)->

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.INTERNET" />

<user-permission android:name="android.ACCESS_COARSE_LOCATION"/>

<uses-sdk android:minSdkVersion="3" />

</manifest>

2 main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello"

/>

<com.google.android.maps.MapView

android:id="@+id/myMapView"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:enabled="true"

android:clickable="true"

android:apiKey="API_Key_String"

/>

</LinearLayout>

3MapSample2.java

public class MapSample2 extends MapActivity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

@Override

protected boolean isRouteDisplayed() {

return false;

}

}

更多相关文章

  1. Android(安卓)与 IOS的UUID的区别
  2. MAC获取Android(安卓)Studio的发布版SHA1和开发版SHA1
  3. android 位图bitmap
  4. android常用的方法
  5. Android(安卓)Map 申请Debug Key的方法
  6. Android(安卓)指定SD卡上一首歌作为程序的背景音乐(进阶篇之Prefe
  7. Android(安卓)ORMLite框架笔记
  8. JSON格式(2)--android中的JSON
  9. Cordova 3.x 基础(5) -- 配置文件config.xml

随机推荐

  1. MyBatis 如何写配置文件和简单使用
  2. win10免安装版本的MySQL安装配置教程
  3. Mac下安装mysql5.7 完整步骤(图文详解)
  4. ubuntu 15.04下mysql开放远程3306端口
  5. Navicat远程连接SQL Server并转换成MySQL
  6. 使用Mysql5.x以上版本出现报错#1929 Inco
  7. MySQL远程连接不上的解决方法
  8. linux下mysql开启远程访问权限 防火墙开
  9. mysql 5.7.16 安装配置方法图文教程(ubunt
  10. ubuntu 16.04下mysql5.7.17开放远程3306