Android IDE (AIDE) Support Forum

How to avoid getIntent() from target activity?

/***** MainActivity *****/
final Bundle extras = getIntent().getExtras();
mDatalist = extras.getParcelableArrayList(KEY_DATALIST);

	mAdapter = new MainAdapter(this, mDatalist);
	mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
	mRecyclerView.setHasFixedSize(true);
	mRecyclerView.setAdapter(mAdapter);

/***** CleonActivity *****/
intent.putParcelableArrayListExtra(“KEY_DATALIST”, mDataset);

(***)

It works. I can retrieve the arraylist data from CleonActivity.java to MainActivity.java…
But i have other activities that when i want to intent to MainActivity, the app crash:

Intent intent = new Intent(N1Activity.this, MainActivity.class);
startActivity(intent);

I know its because getIntent() in the MainActivity. How to avoid it? Please help, i am stuck. Thank you.

There is at least another ways, and that is through the Bundle object in the onCreate method.

https://www.tutorialspoint.com/how-to-pass-multiple-data-from-one-activity-to-another-in-android

If you want to continue with intents, theres a tool called intent intercept, you can find it on F-droid. Also make sure you declared these extra Activities in the Manifest or the app crashes.