For instance: I have 2 activities. Activity A and B. Activity B starts a service as soon it gets launched.
But I want to start the service through activity A, so I need to somehow start Activity B from A without showing it on screen Step #1: Call startService() in Activity A Step #2: There is no step #2 If you want to have some common code, where either Activity A or Activity B can start the service, create a static method, or create a base class that both A and B inherit from.
For instance: I have 2 activities. Activity A and B. Activity B starts a service as soon it gets launched.
But I want to start the service through activity A, so I need to somehow start Activity B from A without showing it on screen Step #1: Call startService() in Activity A. Step #2: There is no step #2. If you want to have some common code, where either Activity A or Activity B can start the service, create a static method, or create a base class that both A and B inherit from.
Yeah but the problem is that the Service uses a method inside Activity B. And if I use startService() from Activity A, I get a nullpointerexception, because the values in Activity B haven't been initiated. – Carnal Apr 26 at 13:05 1 @Carnal: "Yeah but the problem is that the Service uses a method inside Activity B" -- get rid of that.
You should never be doing that. To clarify, a Service should not be trying to call methods on an Activity. The Activity can be destroyed at any point by Android.
If a Service can reach the Activity, you have a memory leak. I guarantee you that there are better solutions for whatever problem you are trying to solve this way. – CommonsWare Apr 26 at 13:18 My problem that is close to the first one is to start my application an an activity that the User choose.So typically, I start ActivityA by default, than ActivityA check preferences and Launch ActivityB,C,D... than ActivityA close.
How can I achieve this? – Profete162 Apr 26 at 13:46.
Activity A and B. Activity B starts a service as soon it gets launched. Step #1: Call startService() in Activity A.
Step #2: There is no step #2. If you want to have some common code, where either Activity A or Activity B can start the service, create a static method, or create a base class that both A and B inherit from.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.