The best way to pass parameter between activites is to use the putExtra() method. Passing an object is possible by putParcelable(). But not all objects are parcelable. If you want to pass a not parcelable object how could you do this?
I have solved this by making a static object-variable in the target activity and fill this variable in the calling activity. Is this a good possibility or shouldn't I do this. If yes, why? Could this cause any problems?
Example:
MainActivity
class FirstActivity extends AppCompatActivity {
MyOwnNotParcelableObject mObject;
public void openNextActivity() {
final Intent intent = new Intent(this, SecondActivity.class);
SecondActivity.mObject = mObject; //<--Fills the static variable
startActivity(intent);
}
}
SecondActivity
class SecondActivity extends AppCompatActivity {
static MyOwnNotParcelableObject mObject;
}