Answers for "how to pass data to another activity in android"

3

send variable intent

String sessionId = getIntent().getStringExtra("EXTRA_SESSION_ID");
Posted by: Guest on May-27-2020
2

send variable intent

Intent intent = new Intent(getBaseContext(), SignoutActivity.class);
intent.putExtra("EXTRA_SESSION_ID", sessionId);
startActivity(intent);
Posted by: Guest on May-27-2020
0

pass data from activity to fragment android

Bundle bundle = new Bundle();
bundle.putString("edttext", "From Activity");
// set Fragmentclass Arguments
Fragmentclass fragobj = new Fragmentclass();
fragobj.setArguments(bundle);

And inside fragment:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    String strtext = getArguments().getString("edttext");    
    return inflater.inflate(R.layout.fragment, container, false);
}
Posted by: Guest on January-22-2021
0

android studio pass value to another activity

Intent i = new Intent(this, ActivityTwo.class);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete);
String getrec=textView.getText().toString();

//Create the bundle
Bundle bundle = new Bundle();

//Add your data to bundle
bundle.putString(“stuff”, getrec);

//Add the bundle to the intent
i.putExtras(bundle);

//Fire that second activity
startActivity(i);
Posted by: Guest on August-17-2021

Code answers related to "how to pass data to another activity in android"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language