

val sendIntent Intent () sendIntent.action Intent.ACTIONSEND sendIntent.putExtra ( Intent.EXTRATEXT. Retrieve the data back in the launched Fragment in the onCreateView method. So, In this section, we’ll share a simple text using intent. Step 1 Create a new project in Android Studio, go to File New Project and fill all required details to create a new project. String value = getIntent().getExtras().getString('my_key') Ĭreate a bunlde and put your key and value to it, then set the argument of the framgent with this bundle. This example demonstrates how to pass an arrayList to another activity using intents in Android Kotlin. To retrieve the data from the launched activity in the onCreate method. All we have to do is add the data to Intent object using putExtra() method.

Passing data to activity using a new Bundle. We can send data while calling one activity from another activity using intent. Passing data to activity using the Bundle from the Intent. Activity to Activity, Activity to Fragment. While starting another use putExtra method of the intent. Intent intent = new Intent(this, MyActivity.class) In the Android projects, data-passing from here to there (e.g. Passing data to activity using the putExtra() directly on the intent. This example demonstrates how do I pass an arrayList to another activity using intends in android. In the following examples, the primitve type string is used for demonstration purpose. Bundle has put and get methods for all primitive types, Parcelables, and Serializables. When passing data to an activity or a fragment in Android, the Bundle is used to contain the data and ship it to the activity or fragment to be launched.
