加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Google Places API在发布后崩溃

发布时间:2020-05-24 08:24:14 所属栏目:Java 来源:互联网
导读:我一直在尝试将Google Places API集成到我的应用程序中,但似乎无法启动API.每次单击按钮启动API时,它都会加载,然后恢复到主屏幕.我相信我已经遵循了API文档中的所有步骤,但似乎似乎无法找到问题.我的代码如下:Java类:package lgalle19.developements.findpl

我一直在尝试将Google Places API集成到我的应用程序中,但似乎无法启动API.每次单击按钮启动API时,它都会加载,然后恢复到主屏幕.我相信我已经遵循了API文档中的所有步骤,但似乎似乎无法找到问题.我的代码如下:

Java类:

package lgalle19.developements.findplaces;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;


public class PlacePickerActivity extends ActionBarActivity {
private static final int PLACE_PICKER_REQUEST = 1;
private TextView mViewName;
private TextView mViewAddress;
private TextView mViewAttributions;
private Button mPickerButton;

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

    mViewName = (TextView) findViewById(R.id.textView);
    mViewAddress = (TextView) findViewById(R.id.textView2);
    mViewAttributions = (TextView) findViewById(R.id.textView3);
    mPickerButton = (Button) findViewById(R.id.pickerButton);
}

public void onPickButtonClick(View v) {
    // Construct an intent for the place picker
    try {
        PlacePicker.IntentBuilder intentBuilder =
                new PlacePicker.IntentBuilder();
        Intent intent = intentBuilder.build(this);
        // Start the intent by requesting a result,// identified by a request code.
        startActivityForResult(intent,PLACE_PICKER_REQUEST);

    } catch (Exception e){
        e.printStackTrace();
    }
}

@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {

    if (requestCode == PLACE_PICKER_REQUEST
            && resultCode == Activity.RESULT_OK) {

        // The user has selected a place. Extract the name and address.
        final Place place = PlacePicker.getPlace(data,this);

        final CharSequence name = place.getName();
        final CharSequence address = place.getAddress();
        String attributions = PlacePicker.getAttributions(data);
        if (attributions == null) {
            attributions = "";
        }

        mViewName.setText(name);
        mViewAddress.setText(address);
        mViewAttributions.setText(Html.fromHtml(attributions));

    } else {
        super.onActivityResult(requestCode,resultCode,data);
    }
}
}

主XML:

表现:


摇篮:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "lgalle19.developements.findplaces"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs',include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.5.0'
}

logcat的:

08-07 13:25:37.053  29527-29527/lgalle19.developements.findplaces E/Zygote﹕ MountEmulatedStorage()
08-07 13:25:37.053  29527-29527/lgalle19.developements.findplaces E/Zygote﹕ v2
08-07 13:25:37.053  29527-29527/lgalle19.developements.findplaces I/libpersona﹕ KNOX_SDCARD checking this for 10245
08-07 13:25:37.053  29527-29527/lgalle19.developements.findplaces I/libpersona﹕ KNOX_SDCARD not a persona
08-07 13:25:37.053  29527-29527/lgalle19.developements.findplaces I/SELinux﹕ Function: selinux_compare_spd_ram,SPD-policy is existed. and_ver=SEPF_SM-G920V_5.0.2 ver=27
08-07 13:25:37.063  29527-29527/lgalle19.developements.findplaces I/SELinux﹕ Function: selinux_compare_spd_ram,priority [1],priority version is VE=SEPF_SM-G920V_5.0.2_0027
08-07 13:25:37.063  29527-29527/lgalle19.developements.findplaces E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL,cateogry: NULL
08-07 13:25:37.063  29527-29527/lgalle19.developements.findplaces I/art﹕ Late-enabling -Xcheck:jni
08-07 13:25:37.083  29527-29527/lgalle19.developements.findplaces D/TimaKeyStoreProvider﹕ TimaSignature is unavailable
08-07 13:25:37.083  29527-29527/lgalle19.developements.findplaces D/ActivityThread﹕ Added TimaKeyStore provider
08-07 13:25:37.153  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ Inside getClassLibPath + mLibMap{0=,1=}
08-07 13:25:37.163  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ Inside getClassLibPath caller
08-07 13:25:37.203  29527-29527/lgalle19.developements.findplaces D/InjectionManager﹕ InjectionManager
08-07 13:25:37.203  29527-29527/lgalle19.developements.findplaces D/InjectionManager﹕ fillFeatureStoreMap lgalle19.developements.findplaces
08-07 13:25:37.213  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ Constructor lgalle19.developements.findplaces,Feature store :{}
08-07 13:25:37.213  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ featureStore :{}
08-07 13:25:37.273  29527-29527/lgalle19.developements.findplaces D/PhoneWindow﹕ *FMB* installDecor mIsFloating : false
08-07 13:25:37.273  29527-29527/lgalle19.developements.findplaces D/PhoneWindow﹕ *FMB* installDecor flags : -2139029248
08-07 13:25:37.333  29527-29527/lgalle19.developements.findplaces D/Activity﹕ performCreate Call Injection manager
08-07 13:25:37.333  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ dispatchOnViewCreated > Target : lgalle19.developements.findplaces.PlacePickerActivity isFragment :false
08-07 13:25:37.353  29527-29561/lgalle19.developements.findplaces D/OpenGLRenderer﹕ Render dirty regions requested: true
08-07 13:25:37.363  29527-29527/lgalle19.developements.findplaces D/PhoneWindow﹕ *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
08-07 13:25:37.363  29527-29527/lgalle19.developements.findplaces D/PhoneWindow﹕ *FMB* isFloatingMenuEnabled return false
08-07 13:25:37.473  29527-29561/lgalle19.developements.findplaces D/libEGL﹕ loaded /vendor/lib64/egl/libGLES_mali.so
08-07 13:25:37.513  29527-29561/lgalle19.developements.findplaces I/OpenGLRenderer﹕ Initialized EGL,version 1.4
08-07 13:25:37.523  29527-29561/lgalle19.developements.findplaces I/OpenGLRenderer﹕ HWUI protection enabled for context,&this =0x7fa4c75060,&mEglDisplay = 1,&mEglConfig = -1529904464
08-07 13:25:37.523  29527-29561/lgalle19.developements.findplaces D/OpenGLRenderer﹕ Get maximum texture size. GL_MAX_TEXTURE_SIZE is 8192
08-07 13:25:37.523  29527-29561/lgalle19.developements.findplaces D/OpenGLRenderer﹕ Enabling debug mode 0
08-07 13:25:37.523  29527-29561/lgalle19.developements.findplaces D/mali_winsys﹕ new_window_surface returns 0x3000,[1440x2560]-format:1
08-07 13:25:37.553  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ dispatchCreateOptionsMenu :lgalle19.developements.findplaces.PlacePickerActivity
08-07 13:25:37.553  29527-29527/lgalle19.developements.findplaces I/InjectionManager﹕ dispatchPrepareOptionsMenu :lgalle19.developements.findplaces.PlacePickerActivity
08-07 13:25:37.673  29527-29527/lgalle19.developements.findplaces I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@3d2a49fa time:246449518
08-07 13:25:42.163  29527-29527/lgalle19.developements.findplaces D/ViewRootImpl﹕ ViewPostImeInputStage ACTION_DOWN
08-07 13:25:42.813  29527-29561/lgalle19.developements.findplaces D/OpenGLRenderer﹕ endAllStagingAnimators on 0x7faaf61e00 (RippleDrawable) with handle 0x7f966ee140
08-07 13:25:46.713  29527-29561/lgalle19.developements.findplaces D/mali_winsys﹕ new_window_surface returns 0x3000,[1440x2560]-format:1
08-07 13:25:46.813  29527-29527/lgalle19.developements.findplaces I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@3d2a49fa time:246458658

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读