tags:

views:

119

answers:

2

Hi, iam trying to run an activity from diffrent package from my remote service: this is how i implement the service.java

  public class CurrencyService extends Service
  {
    public class CurrencyServiceImpl extends ICurrencyService.Stub
    {

    int CALL_PUSH_SERVICE_ACTIVITY=10;


    @Override
    public void callSomeActivity(int activityId) throws RemoteException
    {
            Intent pushActivity=new Intent("com.pushservice.PushActivity");
            pushActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            startActivity(pushActivity);
     }
     .....

}

ive also added a line in the manifest of the service:

the service works fine, but i cant run the activity -> PushActivity which is in diffrent package of diffrent application, this is the error:

Activity not found Exception: No Activity found to handle Intent {act=com.pushservice.PushServiceActivity flq=0x10 ...

thanks.

A: 

You are attempting to open an Activity that has an intent-filter with an action of "com.pushservice.PushActivity". You do not have an Activity that has an intent-filter with an action of "com.pushservice.PushActivity".

The best answer is to not display an activity from a service, since users will be very irritated with you if you interrupt them when they are using the device.

CommonsWare
Yes, but my attention with this activity, is not to up any gui which will interrupt the user,but just to do something else in the background but just to work in the background (have no screen that will show up).. how do i have to adjust my manifest in order to run it?
Moshik
You cannot have an activity "just to do something else in the background but just to work in the background (have no screen that will show up)". That is what services are for.
CommonsWare
Okie, so ill put it else where, how will you call from a remote service, to another remote service to do another job.. i want to have a modular system, that each remote service will be responsible on some part of the system.
Moshik
and yes, i am quite sure ive seen an app which operates without gui, it wont work as service in the background, but you can make it to create some operations(and then being closed) without taking the user's focus - have you ever seen something like that?
Moshik
You absolutely *DO NOT WANT TO CREATE LOTS OF REMOTE SERVICES*. Each remote service takes up a process, consuming lots of extra RAM, on a device that does not have much RAM to begin with. Your design needs to recognize the limitations of the architecture you are building for.
CommonsWare
So how would you replace those remote services? with what? i`am trying to implement some kind of "dispatcher", which listen to servers, and then dispatch the msg to the right application/service/remote service.. how would you recommand to the design this, thank you for your help.
Moshik
Put all of your code in one app. Communicate internally using methods. Use Intents to communicate with third party apps, or *perhaps* create an AIDL interface that third-party apps can implement that you bind to.
CommonsWare
"Put all of your code in one app" - not sure it's good, i want my system to be modular. my system is designed by many parts..about the option of create an AIDL interface.. i did this with remote service, how would u use this option without remote service? do you have some sample for me? thanks again.
Moshik
ive opend new thread with this question, mybe it will be more clear this way: http://stackoverflow.com/questions/2743300/android-system-design-suggestion
Moshik
+1  A: 

You shouldn't call start activity from your service. From Android developers best practice:

Instead of spawning Activity UIs directly from the background, you should instead use the NotificationManager to set Notifications. These will appear in the status bar, and the user can then click on them at his leisure, to see what your application has to show him.

hara