So I have an Activity that I want to pass trough an intent, but it keeps crashing with the following exception: java.io.NotSerializableException: android.content.Intent
public class MainActivity extends AppCompatActivity implements Serializable{
/* some code */
detailIntent = new Intent(MainActivity.this, MovieActivity.class);
detailIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
detailIntent.putExtra("MainActivityReference",this);
startActivity(detailIntent);
}
If you guys could point out my mistake I would be gratefull! Thanks in advance!
So I have an Activity that I want to pass trough an intent
That is not possible, sorry.
Even if you could make Activity
implement Serializable
properly (which is not possible), passing values by Intent
extras makes copies . It is pass-by-value, not pass-by-reference. Your MovieActivity
would have a useless MainActivityReference
extra, pointing to some incomplete, detatched copy of your MainActivity
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.