Android Question NB6 notification action - open activity? [solved]

lte5000

Member
Licensed User
Longtime User
Maybe this should be in the wish list forum, not sure.

With barx old Notification Builder library, we could set a notification action to open either an activity or a service.

Would it be possible to add the option for an action to open an activity with the NB6 library?

When opening a service from a notification action, and then starting an activity from that service, I can't seem to achieve the same result I got with barx's library. (It doesn't work properly from the lockscreen, opens behind the notification drawer, etc)

Thanks!
 
Add this sub to NB6 class:
Code: Copy
'Similar to AddButtonAction. Starts an activity instead of a service.
Public Sub AddButtonAction2 (Bmp As Bitmap, Title As Object,  Activity As Object, Action As String) As NB6
   If IsBuilder = False Then Return Me
   Dim in As Intent = CreateIntent(Activity, False)
   in.Action = Action
   in.Flags = Bit.Or(268435456, 131072) 'FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_REORDER_TO_FRONT
   Dim PendingIntent As Object = PendingIntentStatic.RunMethod("getActivity", Array(ctxt, Rnd(0, 0x7fffffff), in, 0))
   NotificationBuilder.RunMethod("setContentIntent", Array(PendingIntent))
   Dim Ac As Object = CreateAction(Bmp, Title, PendingIntent)
   NotificationBuilder.RunMethod("addAction", Array(Ac))
   Return Me
End Sub

Example of Activity code that reads the action:
Code: Copy
Sub Process_Globals
   Private PrevIntent As Intent
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
End Sub

Sub Activity_Resume
   If Activity.GetStartingIntent <> PrevIntent Then
       PrevIntent = Activity.GetStartingIntent
       Activity.Title = PrevIntent.Action
   End If
End Sub
 
Upvote 0

Similar Threads

  • Question Question
Android Question NB6 + Target SDK 33
Replies
6
Views
6K
Replies
1
Views
4K
Replies
11
Views
16K
  • Question Question
Android Question NB6 example-problem
Replies
1
Views
4K
Back
Top