Skip to content Skip to sidebar Skip to footer

Using Application Service In Another Application

I have an android application which contains a service. Now I want to access that service in another application. How can I do that? I found this application over net. please find

Solution 1:

need to use an intent filter for service, say for 'LocalWordService' we declare

<serviceandroid:enabled="true"android:exported="true"android:name="de.vogella.android.ownservice.local.MyService"><intent-filter><actionandroid:name="de.vogella.android.ownservice.local.START_SERVICE" /></intent-filter></service>

in calling app, we just need to add the line for getting service

Intent intent=newIntent("de.vogella.android.ownservice.local.START_SERVICE");  
                startService(intent);

that's it.

Solution 2:

You need to make your service publicly available so that another application can bind to it. To do that add

android:export="true"

to the manifest entry for the service that you want to share.

You don't need to put that service in a separate process, so you can remove the

android:process=":meinprocess"

unless you want to do that for other reasons.

Solution 3:

Are you wanting to use a certain method in class b from class a? If so, put your initialization of the class with your variables on the top of the class. THEN, in your OnCreate() method, initiate a new object of that class.

EX: //class a initialization Private a mA;

publicvoidOnCreate(Bundle savedInstanceState)
{
   super.OnCreate(savedInstanceState);
   setContentView(R.layout.main);
   //Other code
   mA = newa();
}

Post a Comment for "Using Application Service In Another Application"