`

android map debugkey 和发布环境key的生产

阅读更多
android 内置了Google Map的功能,所以在GPS,SNS及LBS方面编程非常的方便,手机端地图编程为web端编程一样,首先都是需要得到Map key,然后才可以进一步使用。下面就我自己在学习过程中生成android mapkey的一些经验

  生成key大概需要一下步骤:

    1.首先生产可签名文件,在模拟器环境下,可以用android提供的debug.keystore,在发布环境下,需要自己生产keystore文件。生成的步骤也很简单。
     右击项目--》android tools --》export signed application package。然后在弹出的对话框中输入需要输入的内容,就ok了
    2.根据签名文件,使用keystore得到MD5

       debug模式下:
          
        模拟器测试使用的证书文件可以在eclipse菜单的 Window -> Preferences -> Android –> Build 中找到,在窗口中找到:default debug keystore对应的值,就是keystore文件的路径。
       现在假设:电脑名称为:test ,keystore路径为:C:\Documents and Settings\test\.android\debug.keystore,则在cmd命令窗口中输入:keytool -list -alias androiddebugkey - keystore " C:\Documents and Settings\test\.android\debug.keystore" -storepass android -keypass android
    ( 如果系统提示找不到命令,则需要将android的tools路径加入到环境变量path中,和设置java环境变量一样。)
执行结果:指纹认证<MD5>: XX:XX:XX:XX:XX:XX:XX:XX.............
       
        生产环境下:

        在cmd中输入:keystore -list -keystore "自己使用eclipse生产的key所在路径,生产的key可能没有后缀keystore,没有影响"
         然后提示输入密码,输入自己的密码,就可以看到输入下面内容:
[img][/img]
     
     3.得到MD5,就可以去 http://code.google.com/android/maps-api-signup.html生产mapkey了
    
      4.根据生产的key,在Mapview中设置就可以实现地图了,
下面是列子:

   layout文件:

          <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<com.google.android.maps.MapView
android:id="@+id/map" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:enabled="true"
android:clickable="true" android:apiKey="上面得到key">
</com.google.android.maps.MapView>
</LinearLayout>

   manifest文件:
         <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".DisplayMap" 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>

java代码

            public class DisplayMap extends MapActivity {

private MapView mMapView;
private MapController mMapController;
private GeoPoint mGeoPoint;

@Override
protected void onCreate(Bundle icicle) {
// TODO Auto-generated method stub
super.onCreate(icicle);
setContentView(R.layout.display);

mMapView = (MapView) findViewById(R.id.map);
// 设置为交通模式,具体不同的模式可以设置为true和false去测试
// mMapView.setTraffic(true);
// 设置为卫星模式
// mMapView.setSatellite(true);
// 设置为街景模式
// mMapView.setStreetView(true);
// 取得MapController对象(控制MapView)
//mMapView.setTraffic(true);
mMapView.setSatellite(false);
mMapController = mMapView.getController();
mMapView.setEnabled(true);
mMapView.setClickable(true);
// 设置地图支持缩放
mMapView.setBuiltInZoomControls(true);

// 设置起点为广州
mGeoPoint = new GeoPoint((int) (23 * 1000000), (int) (113 * 1000000));
// 定位到广州
mMapController.animateTo(mGeoPoint);//以滑动的效果显示
// 设置倍数(1-21)
mMapController.setZoom(12);
// 添加Overlay,用于显示标注信息

}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
  这样就ok了
  • 大小: 3.8 KB
  • 大小: 3.8 KB
分享到:
评论

相关推荐

    Android Google Map API 开发基础知识

    一、申请google Maps API key(用于开发和debug) 二.Google Map API的使用 三.实例开发

    android开发入门与实战(下)

    第13章 Android综合案例二——基于GoogleMap开发个人移动地图 13.1 项目UI规划 13.2 数据存储实现 13.2.1 设计数据库及表结构 13.2.2 设计SharePreference存储 13.3 项目实现流程 13.3.1 创建项目工程 13.3.2 项目各...

    《Google Android开发入门与实战》.pdf

     本书内容上涵盖了用android开发的大部分场景,从android基础介绍、环境搭建、sdk介绍、market使用,到应用剖析、组件介绍、实例演示等方面。从技术实现上,讲解了5个android平台下的完整综合实例及源代码分析,...

    android开发入门与实战(上)

    第13章 Android综合案例二——基于GoogleMap开发个人移动地图 13.1 项目UI规划 13.2 数据存储实现 13.2.1 设计数据库及表结构 13.2.2 设计SharePreference存储 13.3 项目实现流程 13.3.1 创建项目工程 13.3.2 项目各...

    Google.Android开发入门与实战

     《Android开发入门与实战》内容上涵盖了用Android开发的大部分场景,从Android基础介绍、环境搭建、SDK介绍、Market使用,到应用剖析、组件介绍、实例演示等方面。从技术实现上,讲解了5个Android平台下的完整综合...

    Android Platform Developer‘s Guide.doc

    6. Debug Android-specific init programs on RAMdisk 39 7. Verify that applications have started 40 8. Pulling it all together 40 Android Init Language 41 Display Drivers 46 In this document 46 ...

    Google Android开发入门与实战的代码

    第13章 Android综合案例二——基于Google Map开发个人移动地图 221 13.1 项目UI规划 221 13.2 数据存储实现 222 13.2.1 设计数据库及表结构 222 13.2.2 设计SharePreference 存储 223 13.3 项目实现...

    疯狂Android讲义源码

     1.3.4 Android Debug Bridge(ADB)  的用法 16  1.3.5 使用DX编译Android应用 18  1.3.6 使用Android Asset Packaging  Tool(AAPT)打包资源 19  1.3.7 使用mksdcard管理虚拟SD卡 19  1.4 开始第一个...

    Polaris.zip

    Polaris介绍: ... public static final String GOOGLE_MAPS_API_KEY_DEBUG = "&lt;YOUR_DEBUG_KEY&gt;"; }   测试环境: Eclipse 4.2, Android 3.0 以上。 注意:测试环境并不代表适用环境。  

    MapView的使用

    android:apiKey="Map_Demo" android:clickable="true" /&gt; &lt;EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="输入查询地址" android:selectAll/&gt; ...

    疯狂Android讲义.part1

    第1章 Android应用与开发环境 1 1.1 Android的发展和历史 2 1.1.1 Android的发展和简介 2 1.1.2 Android平台架构及特性 3 1.2 搭建Android开发环境 5 1.2.1 下载和安装Android SDK 5 1.2.2 安装Eclipse和ADT插件 7 ...

    带Key可运行的BaidumapSDK Demo

    原装Baidumapsdk 3.5的demo,加入了自己申请的AK,同时压缩包里包含了自己定义的mydebug.keystore, 在eclipse中 Window-&gt;Preferences-&gt;Android-&gt;Build 页面的custom debug keystore中选择该文件,导入我的工程,就可以...

    adb1.0.26包含fastboot.exe

    ADB,即 Android Debug Bridge,它是 Android 开发/测试人员不可替代的强大工具,也是 Android 设备玩家的好玩具。 注:有部分命令的支持情况可能与 Android 系统版本及定制 ROM 的实现有关。 基本用法 命令语法 ...

    基于谷歌地图Google Maps功能开发的类库

    public static final String GOOGLE_MAPS_API_KEY_DEBUG = ""; } Note: Polaris relies on the Google Maps Android API v1 which as been officially deprecated as of December3rd, 2012. Because of this ...

    hls.min.js

    "symbol":typeof t},l={trace:i,debug:i,log:i,warn:i,info:i,error:i},u=l,d=function(t){if(!0===t||"object"===(void 0===t?"undefined":s(t))){o(t,"debug","log","info","warn","error");try{u.log()}catch(t){...

    EurekaLog_7.5.0.0_Enterprise

    4)....Added "--el_injectjcl", "--el_createjcl", and "--el_createdbg" command-line options for ecc32/emake to inject JEDI/JCL debug info, create .jdbg file, and create .dbg file (Microsoft debug format...

    r40_tinav2.1_最终验证通过_使用CB-S来验证OV5640有横条纹fpscamera+SPI2.0成功_20171114_1443没有外层目录.7z

    2、(可选修改/根据和全志R16平台的tina v1.0的系统下的SDK对照发现的问题。全志R16的最新的tina v2.1大幅度修改cameratest的源代码了!) W:\ov5640_spi20_r40t\package\allwinner\cameratest\src\common\hawkview....

    ap6212a0_a33_sc3817r_服务器验证通过_bt已经通了_wifi需要修改配置_需要再次验证_20170626_1549.7z

    # frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \ # frameworks/native/data/etc/android....

Global site tag (gtag.js) - Google Analytics