Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

android - Place Picker Automatically close after launch

I want to show place picker so that user can choose location of his/her own choice. But place picker child activity automatically closes after launch. I've check the API key multiple times and other permissions, everything is correct. Here is all the code. Please help!

task_location.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
                Intent intent = intentBuilder.build(NewTaskActivity.this);
                // Start the Intent by requesting a result, identified by a request code.
                startActivityForResult(intent, 123);


            } catch (GooglePlayServicesRepairableException e) {
                GooglePlayServicesUtil
                        .getErrorDialog(e.getConnectionStatusCode(), NewTaskActivity.this, 0);
            } catch (GooglePlayServicesNotAvailableException e) {
                Toast.makeText(NewTaskActivity.this, "Google Play Services is not available.",
                        Toast.LENGTH_LONG)
                        .show();
            }
        }
    });

And here is the menifest file.

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

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    tools:replace="android:icon">

    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyAjM9hWUXm8vlABqFbM_fJfQgIFli8HP1E"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please check the logcat of your app for 'PLACES_API_ACCESS_NOT_CONFIGURED' message. If this is the case, enabling the Google Places API for Android in your Google Developer Console for this project should solve your problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...