我一直在尝试将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);
} …Run Code Online (Sandbox Code Playgroud)