Android Question Service Question

anaylor01

Well-Known Member
Licensed User
Longtime User
When my app is open it works fine. But when I use Exitapplication it doesn't seem to work. Now under running applications it shows my app with 1 process and 1 service running. This is for an alarm clock. The only code I have in my service is this
Sub Service_Start (StartingIntent As Intent)
CallSubDelayed(Main, "run_tm")
End Sub

Any ideas???
 

mangojack

Expert
Licensed User
Longtime User
What is "tet" ?

In the timer service process globals ..
B4X:
Dim Notif As Notification

then
B4X:
Sub Service_Create  
  
  Notif.Initialize
  Notif.Icon = "icon"
  Notif.SetInfo("Alarm Clock","my alarm is running ...",Main)
  Notif.Sound = False
  Notif.Notify(1)  
  
  Service.StartForeground(1,Notif)  'do NOT change to "Timer"
  
End Sub[code]
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
"txt" was just a text value. Was supposed to be "test". This service needs to run without notification. It will be running at all times.
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Here is what needs to happen. The user sets the alarm. The app closes. When the specified time is reached the app opens back up.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I might be wrong .. but if a service is to continually run (not be killed by OS) by using Service.StartForeground it Must display Notification to user.

No. This is how Android is designed. If you want your service to be treated as a foreground service then an icon must be shown. You may play with the icon and put a transparent icon.

Erel

Maybe read this Suppress notification for Service.StartForeground ....
 
Last edited:
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
So the alarm clock that comes with android doesn't need a notification because it is part of the OS?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
unsure .. my alarm clock displays notification. maybe look at transparent Icon with no text ... maybe wait for a guru to reply
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Ok check this out. Pandora has an alarm you can use to wake up to Pandora. It uses the same Icon as Android Clock Icon. So now I have to figure out how to use the system Icon.
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Yes they use the same image for their notification ? It should be available from the Android SDK
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Well that is my question how do I make it use the same one in my app so it would appear as the default alarm.
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
If you are asking the way to find the icon, you should find it on your HD in your Android's folder.
For example : C:\Android\platforms\android-19\data\res\drawable-xhdpi\ic_audio_alarm.png

Just import this image using B4A's "Files" tab and "Add files". Then use the reference to the file. For example : LoadBitmap(File.DirAssets, "ic_audio_alarm.png")
 
Upvote 0

anaylor01

Well-Known Member
Licensed User
Longtime User
Well what I am trying to do is not to create another alarm icon. I want to use it just like Pandora and other apps do. So if set the Pandora alarm the same icon and location shows up as if you set the system alarm.
 
Upvote 0
Top