Can't assigned Latlng from Bundle

31 views Asked by At

I run the debugger and get these details

If the bundle has the Latlng, then why I can't assign it to the global variable?

This is InputTempatActivity class where I get the Latlng:

private Agenda agenda;
private Intent intent, intent2;
private Bundle args, args2;
private List<Address> addresses;
private LatLng latLng;

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

    intent = getIntent();
    args = intent.getBundleExtra("BUNDLE"); \\This is from MapsActivity
    addresses = (List<Address>) args.getSerializable("DetailLokasi");
    latLng = new LatLng(addresses.get(0).getLatitude(), addresses.get(0).getLongitude());

    intent2 = new Intent(InputTempatActivity.this, InputKegiatanActivity.class);
    args2 = new Bundle();

    agenda = new Agenda();

    args2.putSerializable("Agenda", agenda);
    args2.putParcelable("Latlng", latLng);
    intent2.putExtra("BUNDLE", args2);
    startActivity(intent2);
}

And this is where I get the problem--at InputKegiatanActivity:

private Intent intent;
private Bundle args;
private LatLng latLng;

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

    intent = getIntent();
    args = intent.getBundleExtra("BUNDLE");
    getAgenda = (Agenda) args.getSerializable("Agenda");
    latLng = args.getParcelable("Latlng");
}

I've tried latLng = (Latlng) args.getParcelable("Latlng") but it's pointless. How do i solve this?

0

There are 0 answers