地方选择器在我的手机上打开了

时间:2017-05-11 14:43:05

标签: android runtime-error google-places-api gmsplacepicker

我用地方选择器制作了一个应用程序。它在我的(API 19)模拟器和我的(android 6.0)朋友手机上打开,但在我的手机中它只是打开一个黑色活动,它关闭后(我的手机也是android 6.0),出现此错误:

 E/AndroidRuntime: FATAL EXCEPTION: main
                                               Process: com.google.android.gms.ui, PID: 19226
                                               Theme: themes:{}
                                               java.lang.RuntimeException: Unable to resume activity {com.google.android.gms/com.google.android.location.places.ui.placepicker.PlacePickerActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.o()' on a null object reference
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3169)
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3200)
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2541)
                                                   at android.app.ActivityThread.access$900(ActivityThread.java:159)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:148)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5504)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.maps.api.android.lib6.impl.bq.o()' on a null object reference
                                                   at com.google.maps.api.android.lib6.impl.da.b(:com.google.android.gms.DynamiteModulesB:96)
                                                   at com.google.android.gms.maps.internal.z.onTransact(:com.google.android.gms.DynamiteModulesB:73)
                                                   at android.os.Binder.transact(Binder.java:387)
                                                   at url.b(:com.google.android.gms:233)
                                                   at upa.a(:com.google.android.gms:127)
                                                   at omy.b(:com.google.android.gms:340)
                                                   at omu.a(:com.google.android.gms:143)
                                                   at com.google.android.gms.maps.MapView.a(:com.google.android.gms:7332)
                                                   at amzd.onResume(:com.google.android.gms:92)
                                                   at com.google.android.chimera.FragmentProxy.onResume(:com.google.android.gms:433)
                                                   at gm.a(:com.google.android.gms:12120)
                                                   at gm.a(:com.google.android.gms:1286)
                                                   at gm.a(:com.google.android.gms:1268)
                                                   at gm.p(:com.google.android.gms:2153)
                                                   at gm.a(:com.google.android.gms:12126)
                                                   at gm.a(:com.google.android.gms:1286)
                                                   at gm.a(:com.google.android.gms:1268)
                                                   at gm.p(:com.google.android.gms:2153)
                                                   at gc.e(:com.google.android.gms:11223)
                                                   at bxe.superOnResumeFragments(:com.google.android.gms:2406)
                                                   at com.google.android.chimera.Activity.onResumeFragments(:com.google.android.gms:384)
                                                   at com.google.android.chimera.Activity.publicOnResumeFragments(:com.google.android.gms:389)
                                                   at bxe.e(:com.google.android.gms:469)
                                                   at gc.onPostResume(:com.google.android.gms:511)
                                                   at bxe.superOnPostResume(:com.google.android.gms:2401)
                                                   at com.google.android.chimera.Activity.onPostResume(:com.google.android.gms:375)
                                                   at bxc.onPostResume(:com.google.android.gms:183)
                                                   at com.google.android.chimera.Activity.publicOnPostResume(:com.google.android.gms:380)
                                                   at bxe.onPostResume(:com.google.android.gms:460)
                                                   at android.app.Activity.performResume(Activity.java:6385)
                                                   at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3158)
                                                   at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3200) 
                                                   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2541) 
                                                   at android.app.ActivityThread.access$900(ActivityThread.java:159) 
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353) 
                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                   at android.os.Looper.loop(Looper.java:148) 
                                                   at android.app.ActivityThread.main(ActivityThread.java:5504) 
                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

代码:

  PLACE_PICKER_REQUEST = 199;
        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
        Context context = this;
        try {
            startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }

结果代码:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            Toast.makeText(this,  place.getAddress(), Toast.LENGTH_LONG).show();

            String toastMsg = String.format("Place: %s", place.getName());
           // Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
            TextView lbl_coordenadas = (TextView) findViewById(R.id.lbl_coordenadas);
            coordenadas=""+place.getName();
            lbl_coordenadas.setText("Coordenadas: "+coordenadas);
        }
    }
}

有没有人知道它可能是什么?提前谢谢。

0 个答案:

没有答案