Notification without Notification?

Roeschti

Member
Licensed User
Longtime User
Strange title, I know...

Is there a way to start an activity from a notification icon in the statusbar / tray bar without clicking the notification frist?

What I have:

A Service what starts at boot and show me my icon in the status bar. If I click on the icon I see my icon and the info text. I click again, then the transparent activity starts and show the system volume user interface to change the volume. It also starts a timer so the activitiy will be finished after 2 secods. Everything works fine, I can change the volume and nothing does lag or hang or block.

But it is really not a lot of fun to click twice to see the volume user interface. Is it possible to start the activity direct after the click on the status bar icon without showing the notification first?
 

Roeschti

Member
Licensed User
Longtime User
That's exactly what happens. To see the volume user interface I have to click on the Notification. But I'm looking for a direct way without seeing the notification screen, just clicking on the icon in the statusbar = start activity and let me see the volume user interface :)

Here my code in the main activity:

B4X:
Sub Process_Globals
   Dim tmrLoud As Timer 
   Dim p As Phone
End Sub

Sub Globals
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   tmrLoud.Initialize("tmrLoud", 2000)
   StartService (modVol)
End Sub

Sub Activity_Resume
   p.SetVolume(p.VOLUME_SYSTEM,p.GetVolume(p.VOLUME_SYSTEM),True)
   tmrLoud.Enabled = True
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub tmrLoud_Tick
   tmrLoud.Enabled = False
   Activity.Finish
End Sub


and the service:

B4X:
Sub Process_Globals
   
End Sub
Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
   Dim n As Notification
   n.Initialize
   n.OnGoingEvent = True
   n.Sound = False
   n.Vibrate = False
   n.Icon = "icon"
   n.SetInfo("Volume", "", Main) 
   n.Notify(1) 
End Sub

Sub Service_Destroy

End Sub
 
Upvote 0
Top