Android Question Where has StartForeground gone?

Arf

Well-Known Member
Licensed User
Longtime User
I'm trying to use Service.StartForeground() to launch a service, instead of making it a sticky service.

However I can't for the life of me figure out the syntax. There doesn't seem to be any autocomplete option for StartForeground, or Service.StartForeground.

Have I gone mad, or am I doing something wrong?

Thanks
 

Arf

Well-Known Member
Licensed User
Longtime User
I've been doing that for the last 30 minutes and have no luck figuring out why my IDE won't let me type it in :-(
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
We are talking about the same thing:
1: Arf searches forums to try find out why he can't type Service.StartForeground(Comms_Service) into has IDE to start a foregroud service.
2: Arf finds many results, all suggesting that Service.StartForeground is the syntax to use
3: Arf tries to type this in, but autocomplete makes it impossible
4: Arf asks for help, and gets sent back to repeat step 1
Loop
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
right, so I just tried typing Service.StartForeground inside a Service module, and autocomplete allows me to do so.
So the problem must be that there is different (or no) syntax for starting a foreground service from inside an Activity.
I guess it's impossible to do so, so I'll just give up rather than risk asking the question.
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
1- Arf should be a little more specific when explaining a problem.
2- Arf spent 30 minutes going in circles because reason #1
3- Arf should ask/post a bug report if AutoComplete didn't work.
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
Does anyone other than NJDude know if it is possible to start a foreground service from within an activity module?
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
I think I got it.
Service.StartForeground is a command that can be used from inside Service_Create, to make that service be a foreground service.
You cannot Start a service as a foreground service from another module. Except maybe from within a different Service Module.
 
Upvote 0

cengolo

Member
Licensed User
Longtime User
whatever i do, service does not start if the phone is sleeping (if the user has closed the screen by pressing the power button). any help will be appreciated.
i develop an alarm application. for example, say alarm is set to 15:15. if phone is awake (even if the app is closed or paused) alarm fires. but if the phone is sleeping, it does not. if i wake the phone by pressing power button, alarm fires, even if the time is 15:17 for example. how can i set the service to start at the given time, wake the phone, play the alarm and display the app?
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Upvote 0
Top