I am trying to pass parameters between two activities which are tabs of tabhost. How do I send a value correctly from an activity (Active.java) to a second activity (Active2.java)? What did I do wrong?
Active.java
public class Active extends Activity {
private Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_active);
// intent = new Intent(this,Active2.class);
intent = getParent().getIntent();
}
public void Location(View view) {
final LocationManager LocMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
final LocationListener LocList = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
LatLng point = new LatLng(latitude, longitude);
intent.putExtra("point", point);
intent.putExtra("Active",1);
TabActivity ta = (TabActivity) Active.this.getParent();
ta.getTabHost().setCurrentTab(1);
}
};
}
Active2.java
public class Active2 extends Activit {
private GoogleMap googleMap;
private GoogleApiClient client;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_active2);
getFragmentManager().findFragmentById(R.id.map)).getMap();
client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
updateGoogleMap();
}
void updateGoogleMap ()
{
Bundle extras = getIntent().getExtras();
if(null !=extras) {
LatLng point = (LatLng) extras.get("point");
TextView text = (TextView) findViewById(R.id.GpsStat) ;
text.setText("bylem");
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.addMarker(new MarkerOptions().position(point).title("point"));
}
}
}