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???
 
What is "tet" ?

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

then
Code: Copy
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
"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
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
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
unsure .. my alarm clock displays notification. maybe look at transparent Icon with no text ... maybe wait for a guru to reply
 
Upvote 0
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
Yes they use the same image for their notification ? It should be available from the Android SDK
 
Upvote 0
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
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
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
Back
Top