How Pass Data from Activity to Services in Android?
Contents

How pass data from activity to service in Android?

Android provides a way to pass values between activity and sub-activities and services and each others, using the getExtras(). putExtra method, which takes the key name (string) and its value. This passed value can be recovered when the intent is handled (being it service or activity).

How pass data from activity to adapter using bundle in Android?

Simply add the values to the constructor.

  1. public SimpleAdapter(Activity context, ArrayList<SimpleBeans> data, String mystring, int myInt){ //use datas here }
  2. myAdapter = new SimpleAdapter(this, data, myString, myInt);
  3. myAdapter = new SimpleAdapter(this, myArrayList);
Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest