Say I have a generic service (not an Android service) that I wish to share between applications
package com.projects.services.someservice
class SomeService {
public SomeService () {}
public void start() { /*start service*/ };
public void stop() { /*stop service*/ }
// other methods...
}
Now say I have two Android application projects (com.projects.app1 and com.projects.app2) which each have their own instance of SomeService. How can I share one instance of the service between the applications? Would I have to refactor the service into an android service and initialise it independently? Or can I pass one application's instance to the other.
I am facing a situation where I start app2 from app1 via an Intent:
// called within an activity in app1
Intent i = getPackageManager().getLaunchIntentForPackage("com.projects.app2");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
What are my options?
0 comments:
Post a Comment