Android Question opening notification

Makumbi

Well-Known Member
Licensed User
Please help i have this notification here which i receive on my phone but when i click on it does not go to the corresponding table where all the notification are saved please help how can i get linked to that table

B4X:
Dim n As NB6
                n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
                n.Build(quot.Get("sms"), "Kabojja Junior School", "tag", Me).Notify(9)
 

Makumbi

Well-Known Member
Licensed User
Please help i have this notification here which i receive on my phone but when i click on it does not go to the corresponding table where all the notification are saved please help how can i get linked to that table

B4X:
Dim n As NB6
                n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
                n.Build(quot.Get("sms"), "Kabojja Junior School", "tag", Me).Notify(9)

That is the entire code
B4X:
Sub replysms
    'Dim SQLQry As String = "DELETE FROM Recievedsms"
    'Starter.SQL1.ExecNonQuery(SQLQry)
    cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
    If cursor1.RowCount > 0 Then
        cursor1.Position =0
        Dim phone As String
        phone = cursor1.Getstring("Phone")
        Dim sx As String
        sx = cursor1.Getstring("Sex")
    '    sx = "Father"
    End If
    Dim CustID As String = phone' Customer ID
    Dim jtk As HttpJob
    jtk.Initialize("", Me)
    'j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVB.ashx?customerid=" & CustID)
    jtk.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
    'jtk.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBGetreply.ashx?customerid=" & CustID & "&bcode=" & sx)
    jtk.GetRequest.Timeout = 10000 ' 10 seconds
    Wait For (jtk) JobDone(jtk As HttpJob)

    If jtk.Success Then ' if job is success (http status code 200)
        Dim RetVal As String
        Log(RetVal)
        RetVal = jtk.GetString
        If jtk.GetString = "[]" Then
            'Msgbox("Please try Again ","SMIS")
            'Return
            
        Else
                    
            Dim jpt As JSONParser
            jpt.Initialize(jtk.GetString)
            Log(jpt) ' will pr
            Dim quotes As List = jpt.NextArray
            For Each quot As Map In quotes
            Log("Account: " & quot.Get("Account"))
            Log("sms: " & quot.Get("sms"))
                Log("Datesent: " & quot.Get("Datesent"))
                Log("Status: " & quot.Get("Status"))
                Log("codes: " & quot.Get("Code"))
                Log("atk: " & quot.Get("atk"))
            'Log("Tos: " & quot.Get("Tos"))
                Dim ltt As Long
                DateTime.DateFormat = "dd/MM/yyyy" ' "1961-08-29"
                Dim datestring As String = DateTime.Date(JsonDateToTick( quot.Get("Datesent")))
                ltt = DateTime.DateParse(datestring)
                DateTime.DateFormat = "dd/MM/yyyy"
                Log(DateTime.Date(ltt))
                Dim now As Long
                now = DateTime.Now
                Log(DateTime.Now)
                DateTime.DateFormat = "dd/MM/yyyy" : DateTime.TimeFormat = "hh:mm a"
                
                Log(DateTime.Date(ltt)& " "& DateTime.Time(now))
                '"SELECT DISTINCT Daterecieved,Sms as RecievedMessage,ID FROM Recievedsms"
                'Starter.SQL1.ExecNonQuery("INSERT INTO Recievedsms VALUES('" & DateTime.Date(ltt) & "','" & quot.Get("sms") & "','" & quot.Get("Code") & "')")
                Starter.SQL1.ExecNonQuery2("INSERT INTO Recievedsms VALUES(?, ?, ?)", Array As Object(DateTime.Date(ltt)& " "& DateTime.Time(now), quot.Get("sms"), quot.Get("Code")))
    
                Dim n As NB6
                n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
                n.Build(quot.Get("sms"), "Kabojja Junior School", "tag", Me).Notify(9)
                
                Dim jtkt As HttpJob
                jtkt.Initialize("", Me)
                jtkt.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBDelReply.ashx?customerid=" &  quot.Get("atk"))
            Next
            
        End If
    
End If
End Sub
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
I mean where does the table exist? Do you want to open an activity which has all the notification listed?
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
Pass the activity(page) name to the last parameter in which the table exists.
B4X:
n.Build(quot.Get("sms"), "Kabojja Junior School", "tag", Activity_Name)

i have tried out this but iam getting error
B4X:
Dim n As NB6
                    n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
                    n.Build(quot.Get("Comments") , "Kabojja Junior School", "tag",Activity.LoadLayout("simplechat")).Notify(9)
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
4
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
[{"Account":"05-00001","Name":"BUGEMBE YASIN ismail","Stream":"A","Category":"Active","Country":"S2","Froms":"\/Date(1545512400000)\/","Tos":"\/Date(1554152400000)\/"}]
(JSONTokener)  at character 0 of [{"CustomerId":null,"Comments":"Please don\u0027t bring water to school admin","Dates":"\/Date(1551533741930)\/","Status":null,"Class":"S2","Stream":"A","Term":null,"Years":null,"Tcode":44}]
Account: null
Events: Please don't bring water to school admin
Class: S2
Stream: A
Years: null
Term: null
Tcode: 44
03/02/2019
02/03/2019
Error occurred on line: 302 (NB6)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Constructor.newInstance0(Native Method)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:90)
    at de.amberhome.slidemenuexample.nb6._createintent(nb6.java:505)
    at de.amberhome.slidemenuexample.nb6._build(nb6.java:221)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:352)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:245)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
    at anywheresoftware.b4a.BA$2.run(BA.java:365)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
    at android.content.ComponentName.<init>(ComponentName.java:129)
    at android.content.Intent.<init>(Intent.java:4868)
    ... 23 more
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i have tried out this but iam getting error
1. You really should learn what you are doing here.
2. You got told to put the activityname of the activity you want to open. Why you are not taking this suggestion?

If you have an Activity named Chat and here you are using your
B4X:
Activity.LoadLayout("simplechat")

so you should put Chat in the Notificationbuilder.

B4X:
Dim n As NB6
                    n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
                    n.Build(quot.Get("Comments") , "Kabojja Junior School", "tag",Chat).Notify(9)
 
Upvote 0

Brandsum

Well-Known Member
Licensed User
n.Build(quot.Get("Comments") , "Kabojja Junior School", "tag",Activity.LoadLayout("simplechat")).Notify(9)
Oh!! you can't load a layout.

Your first screen name is Main which suppose has login functionality, and another screen name is Notification which has the notification table. Then you have to pass the activity or screen name like
B4X:
n.Build(quot.Get("sms"), "Kabojja Junior School", "tag", Notification)
 
Upvote 0
Top