使用场地选择器时出错:无法找到方法android.content.pm.PackageManager.getPackageInstaller

时间:2017-11-09 20:27:43

标签: android google-maps

嘿伙计们,我正面临着这个奇怪的问题,每当我在地方选择器下面运行我的代码时,它会在一秒内消失,然后它会回到我的邮件活动中。我在互联网上的某个地方看到了这个代码并想尝试它。我试图寻找类似的问题,但无法找到它。我正在学习android所以请帮助。谢谢提前

public class Plcpickr extends AppCompatActivity {
int PLACE_PICKER_REQUEST = 1;
Button btn;
TextView t;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_plcpickr);
    btn= (Button)findViewById(R.id.button2);
    t = (TextView)findViewById(R.id.textView);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            PlacePicker.IntentBuilder builder = new 
PlacePicker.IntentBuilder();
            try {
                startActivityForResult(builder.build(Plcpickr.this), 
 PLACE_PICKER_REQUEST);
            } catch (GooglePlayServicesRepairableException | 
GooglePlayServicesNotAvailableException e) {
                e.printStackTrace();
            }
        }
    });
  }
  @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent 
 data) {
    if (requestCode == PLACE_PICKER_REQUEST) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            StringBuilder stBuilder = new StringBuilder();
            String placename = String.format("%s", place.getName());
            String latitude = String.valueOf(place.getLatLng().latitude);
            String longitude = String.valueOf(place.getLatLng().longitude);
            String address = String.format("%s", place.getAddress());
            stBuilder.append("Name: ");
            stBuilder.append(placename);
            stBuilder.append("\n");
            stBuilder.append("Latitude: ");
            stBuilder.append(latitude);
            stBuilder.append("\n");
            stBuilder.append("Logitude: ");
            stBuilder.append(longitude);
            stBuilder.append("\n");
            stBuilder.append("Address: ");
            stBuilder.append(address);
            t.setText(stBuilder.toString());
        }
    }
}
}

Logcat错误

  

/com.example.jimmy.placepicker I / dalvikvm:找不到方法android.content.pm.PackageManager.getPackageInstaller,从com.google.android.gms.common.zzo.zzy 11-09 12方法引用: 41:38.400 10227-10227 / com.example.jimmy.placepicker W / dalvikvm:VFY:无法解析虚方法492:Landroid / content / pm / PackageManager; .getPackageInstaller()Landroid / content / pm / PackageInstaller; 11-09 12:41:38.400 10227-10227 / com.example.jimmy.placepicker D / dalvikvm:VFY:替换操作码0x6e

0 个答案:

没有答案