• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

android - 我们如何在模拟器上测试 Google Map API v2

[复制链接]
菜鸟教程小白 发表于 2022-12-9 06:50:39 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我使用 v2 Version 实现了 Google Map。我在真实设备上测试了应用程序。它工作正常,但我也想在模拟器上测试它。我该怎么做?

这是我的 manifest.xml

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

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

<uses-permission  android:name="com.example.demogooglemapv2.permission.MAPS_RECEIVE"/>


    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

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




    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >


        <activity
            android:name="com.example.demogooglemapv2.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.maps.v2.API_KEY"
            android:value="AIzaSyB2jvxyj-WbkYc1Y1WR9Sc1E1W22QywA_k"
            />
    </application>

</manifest>

这是我的 activity_main.xml

<LinearLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >



    <fragment 
         class="com.google.android.gms.maps.SupportMapFragment"
        android:id="@+id/map"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        />



</LinearLayout>

这是我的 mainActivity.java

package com.example.demogooglemapv2;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

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

import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.Menu;
import android.widget.Toast;

public class MainActivity extends FragmentActivity{

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

        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

          if (resultCode == ConnectionResult.SUCCESS){
           Toast.makeText(getApplicationContext(), 
             "isGooglePlayServicesAvailable SUCCESS", 
             Toast.LENGTH_LONG).show();
          }else{

          }




    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();

        int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());

          if (resultCode == ConnectionResult.SUCCESS){
           Toast.makeText(getApplicationContext(), 
             "isGooglePlayServicesAvailable SUCCESS", 
             Toast.LENGTH_LONG).show();

           Log.v(">>>>>>>>>>>>>.", "successs");
          }else{

          }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}



Best Answer-推荐答案


这个问题我也纠结了很久。我没有一台Android设备可以使用,所以我必须在模拟器上尝试。

我发现让 map 在模拟器上运行的最佳方法是使用另一个模拟器而不是 eclipse 模拟器。

搜索 Genymotion .是我试过的最好的模拟器。您可以使用 google play 下载任何应用程序,并且 map 可以正常工作。

对不起,我的英语不好。

关于android - 我们如何在模拟器上测试 Google Map API v2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17609300/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap