I found this code very usefull to get from one activity to the other but the problem is, that I don’t see where the destination is mentioned. I would really appreciate it if some one pointed out how to change the destination.
Here is the code:
Button getTaxi = (Button) findViewById(R.id.GetTaxi);
getTaxi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
final Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
The respective part in the xml:
<Button
android:id="@+id/GetTaxi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="GetTaxi" >
</Button>
Thank you very much in advance!
Actually, the code that executes on the
Button‘s click states that yourActivity(which is a sub-activity here by the way) has done its job and now finishes with the result codeRESULT_OK. It means that there was anotherActivitythat has started this actualActivityfor some kind of result. So, when you’ll click theButtonyourActivitywill finish. To start some otherActivityon theButton‘s click you should create anIntent, specifying explicitly theActivityyou want to start, or just the action you want to perform over some data, letting the Android resolve the finalActivityfor you. Then you should callstartActivity(), passing in theIntentyou’ve created. Hope this helps.