0

hey guys i am facing this weird issue whenever i run my code below the place picker appears but within a sec it disappears and it goes back to my mail activity. I saw this code somewhere on internet and wanted to try it.i tried looking for similar issues but couldnt find it.i am learning android so please help .Thanks in advance

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 error

/com.example.jimmy.placepicker I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zzo.zzy 11-09 12:41:38.400 10227-10227/com.example.jimmy.placepicker W/dalvikvm: VFY: unable to resolve virtual method 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: replacing opcode 0x6e at

depp
  • 25
  • 6
  • can you put logcat – A.s.ALI Nov 09 '17 at 20:30
  • @SharartiKAKA 11-09 12:41:38.400 10227-10227/com.example.jimmy.placepicker I/dalvikvm: Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.zzo.zzy 11-09 12:41:38.400 10227-10227/com.example.jimmy.placepicker W/dalvikvm: VFY: unable to resolve virtual method 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: replacing opcode 0x6e at 0x0012 – depp Nov 10 '17 at 05:53
  • at exactly which place this error occurr – A.s.ALI Nov 10 '17 at 06:06
  • It comes at the end after i click on the button – depp Nov 10 '17 at 06:09
  • which ok button you are not explaining your situations – A.s.ALI Nov 10 '17 at 06:40
  • in the code above btn.setOnClickListener(new View.OnClickListener() my placepicker is called on the click of a button in the code above so when i run the code the error doesnt appear but when i click on the button to call Placepicker the error appears – depp Nov 10 '17 at 07:02
  • can you place your xml too ? – A.s.ALI Nov 10 '17 at 07:10
  • if there is no problem in your xml consider changing your Google API key. Go to your google developer console and then project , create new key and use it, – A.s.ALI Nov 10 '17 at 07:13
  • i have already tried it but nothing happened still the same error – depp Nov 10 '17 at 07:20
  • which device are you testing on ? – A.s.ALI Nov 10 '17 at 07:44
  • i am testing on bluestack, and i tried using google maps in my another app and its working fine – depp Nov 10 '17 at 14:48
  • u must test on real device – A.s.ALI Nov 13 '17 at 04:21

0 Answers0