Android Question AHQuickAction (1.02) Menu

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi

I am getting an error after I dim the menu in a local function so I can dynamically re-create.

B4X:
Sub Process_Globals

   Dim acChannels As AHQuickAction3D

end sub
Sub Activity_Create(FirstTime As Boolean)


   If FirstTime Then
    
     ' // menu's
     acChannels.Initialize("ac_channels", acChannels.VERTICAL)

   end if

end sub

Sub make_menus_acChannels

   Dim i As Int, s As String
  
   s = "SELECT ptt_users_channels.channel_id, ptt_channels.channel_name FROM ptt_users_channels " & _
     "INNER JOIN ptt_channels ON ptt_users_channels.channel_id=ptt_channels.channel_id ORDER BY ptt_users_channels.channel_id"
   ' // get list of cases for current view
   Dim rs As Cursor    
   rs = SQLDB.ExecQuery(s)
   show_channel_count
   If rs.RowCount = 0 Then
     Return
   End If
  
   ' // re-create the menu
  
   Dim acChannels As AHQuickAction3D
  
  
   For i = 0 To (rs.RowCount-1)
     rs.Position = i
    
     Dim ai As AHActionItem
     Dim bd As BitmapDrawable
     Dim Filename, Text As String
        
     Filename = "walkie_talkie_white_24pxi.png"
     Text = rs.GetInt("ptt_users_channels.channel_id") & "-" & rs.GetString("ptt_channels.channel_name")
     ' // Initialize a bitmap drawable and the action item
     bd.Initialize(LoadBitmap(File.DirAssets, Filename))
     ai.Initialize( rs.GetInt("ptt_users_channels.channel_id") , Text, bd)
     ai.Selected = True    
     acChannels.AddActionItem(ai) <- ERROR HERE Null pointer exception
    
   Next
  
  

End Sub

I too dynamically create the menu.

Regards

John
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Sorry Here is the log data:

B4X:
main_make_menus_acchannels (B4A line: 311)
acChannels.AddActionItem(ai)
main_make_menus_acchannels (B4A line: 311)
acChannels.AddActionItem(ai)
java.lang.NullPointerException
   at de.amberhome.quickaction.QuickAction3D.AddActionItem(QuickAction3D.java:212)
   at com.islesystems.pushtotalk.main._make_menus_acchannels(main.java:1823)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
   at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831)
   at com.islesystems.pushtotalk.svc_ppt_core._process_ptt_channels(svc_ppt_core.java:457)
   at com.islesystems.pushtotalk.svc_ppt_core._service_start(svc_ppt_core.java:586)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
   at com.islesystems.pushtotalk.svc_ppt_core.handleStart(svc_ppt_core.java:95)
   at com.islesystems.pushtotalk.svc_ppt_core.onStartCommand(svc_ppt_core.java:69)
   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3063)
   at android.app.ActivityThread.access$1900(ActivityThread.java:162)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:158)
   at android.app.ActivityThread.main(ActivityThread.java:5751)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
   at de.amberhome.quickaction.QuickAction3D.AddActionItem(QuickAction3D.java:212)
   at com.islesystems.pushtotalk.main._make_menus_acchannels(main.java:1823)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
   at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831)
   at com.islesystems.pushtotalk.svc_ppt_core._process_ptt_channels(svc_ppt_core.java:457)
   at com.islesystems.pushtotalk.svc_ppt_core._service_start(svc_ppt_core.java:586)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
   at com.islesystems.pushtotalk.svc_ppt_core.handleStart(svc_ppt_core.java:95)
   at com.islesystems.pushtotalk.svc_ppt_core.onStartCommand(svc_ppt_core.java:69)
   at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3063)
   at android.app.ActivityThread.access$1900(ActivityThread.java:162)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1474)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:158)
   at android.app.ActivityThread.main(ActivityThread.java:5751)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
   at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0
Top