Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google Place Picker不会一直打开_Android_Google Maps - Fatal编程技术网

Android Google Place Picker不会一直打开

Android Google Place Picker不会一直打开,android,google-maps,Android,Google Maps,我试图在一个小应用程序上使用GoogleAPI位置选择器:问题是位置选择器不能保持打开状态,几秒钟后就会自动关闭。 很多关于堆栈溢出的解决方案都说最常见的原因是错误的清单,但我认为我的情况并非如此。 这是我的清单: <?xml version="1.0" encoding="utf-8"?> 这是我的gradle文件: apply plugin: 'com.android.application' android { compileSdkVersion 25

我试图在一个小应用程序上使用GoogleAPI位置选择器:问题是位置选择器不能保持打开状态,几秒钟后就会自动关闭。 很多关于堆栈溢出的解决方案都说最常见的原因是错误的清单,但我认为我的情况并非如此。 这是我的清单:

<?xml version="1.0" encoding="utf-8"?>
这是我的gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.example.lorenzo.mysimplemap"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.android.gms:play-services-maps:10.2.4'
    compile 'com.google.android.gms:play-services-places:10.2.4'
    testCompile 'junit:junit:4.12'
}
以下是我的主要活动布局:

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent">

<Button
    android:id="@+id/pick_place_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|center"
    android:text="scegli un posto" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lorenzo.mysimplemap.MapsActivity" />

提前感谢您的帮助

多亏了穆希布·皮拉尼,我才解决了问题 我必须在我的开发者控制台页面上启用GooglePlacesAPI。
之后,place picker在我的应用程序上工作。

转到开发者控制台页面->启用api->选择Google places api并为您的项目启用它

您在开发者控制台页面启用Google places api了吗?哎呀,我不知道。。。你能把这个程序写给我吗?
    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.example.lorenzo.mysimplemap"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.google.android.gms:play-services-maps:10.2.4'
    compile 'com.google.android.gms:play-services-places:10.2.4'
    testCompile 'junit:junit:4.12'
}
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent">

<Button
    android:id="@+id/pick_place_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="top|center"
    android:text="scegli un posto" />
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.lorenzo.mysimplemap.MapsActivity" />