1,
My services always auto stoped, but there is no error,
I've try to set the android's "Background process limit".
When I set "Standard limit", then my services will stop after 2~10 mins.
When I set "At most 4 processes", then my services will stop after 1 sec = =!
"Standard limit" (No any error, just need to start the services again after it stoped):
How can I make my services keep alive?
That "s2" service code :
2, About GCM problem
After a long time, when I use gcm send something to my device, it got a error msg.
Is that gcm have a live time too ?
Or just I do something worng...
3, I've write a function in GCM service ( MessageArrived ) to call a service.
In type = 3,
The service is start properly,
But in type = 4,
The service will restart sometimes, and sometimes can stop properly. -_-!!!
Log :
2, type 4 -> It stoped.
3, type 3 -> It started.
4, type 4 -> It stoped.
5, type 3 -> It started.
6, type 4 -> It restarted !!!!!!
7, type 4 -> It restarted !!!!!!
8, type 4 -> It restarted !!!!!!
9, type 4 -> Finally, It know stoped.
4, Fromula problem
4.1, I dim a (NBnum as Int) in (Process_Globals), then I make it when messagearrived one time, it will add 1 it self.
But it didn't, is it because everytimes when GCM coming it will start the services again, so the NBnum will always keep at 10 ?
If is that, can I temp a var in GCM services? or do I need to put NBnum = 10 in (Process_Globals) ? Is there is the right way to do that?
4.2,
"If Line1.Length > 0 Then" this not working - -!
And I've try "If Line1 = "" Then",
is also not working.
It don't care Line1 this var have / don't have value,
And it will do inside if : "nbInboxStyle.AddLine = Line1"
5, Mainfest Problem
I've using Receive SMS method
Can I have a solution :
If s2 is active, just s1 have action.
If s1 is active, just s2 have action.
Doing like this ?
P.S. I attatched my full app source code.
My services always auto stoped, but there is no error,
I've try to set the android's "Background process limit".
When I set "Standard limit", then my services will stop after 2~10 mins.
When I set "At most 4 processes", then my services will stop after 1 sec = =!
"Standard limit" (No any error, just need to start the services again after it stoped):
00:53:11.715 I/B4A (27116): ~i:** Activity (main) Create, isFirst = true **
00:53:11.895 I/B4A (27116): ~i:** Activity (main) Resume **
00:53:12.045 I/B4A (27116): ~i:** Service (s1) Create **
00:53:12.045 I/B4A (27116): ~i:** Service (s1) Start **
00:53:12.055 I/B4A (27116): ~i:** Service (pushservice) Create **
00:53:12.055 I/B4A (27116): ~i:** Service (pushservice) Start **
00:53:13.767 I/B4A (27116): ~i:** Service (pushservice) Start **
00:53:13.797 I/B4A (27116): ~i:** Service (httputils2service) Create **
00:53:13.797 I/B4A (27116): ~i:** Service (httputils2service) Start **
00:53:13.967 I/B4A (27116): ~i:** Service (s1) Destroy **
00:53:13.967 I/B4A (27116): ~i:** Service (s2) Create **
00:53:13.997 I/B4A (27116): ~i:** Service (s2) Start **
00:53:13.997 I/B4A (27116): ~i:** Activity (main) Pause, UserClosed = true **
00:55:20.120 I/B4A (28300): ~i:** Activity (main) Create, isFirst = true **
00:55:20.230 I/B4A (28300): ~i:** Activity (main) Resume **
00:55:20.360 I/B4A (28300): ~i:** Service (s1) Create **
00:55:20.360 I/B4A (28300): ~i:** Service (s1) Start **
00:55:20.370 I/B4A (28300): ~i:** Service (pushservice) Create **
00:55:20.370 I/B4A (28300): ~i:** Service (pushservice) Start **
00:55:21.141 I/B4A (28300): ~i:** Service (pushservice) Start **
00:55:21.161 I/B4A (28300): ~i:** Service (httputils2service) Create **
00:55:21.161 I/B4A (28300): ~i:** Service (httputils2service) Start **
00:55:22.032 I/B4A (28300): ~i:** Service (s1) Destroy **
00:55:22.032 I/B4A (28300): ~i:** Service (s2) Create **
00:55:22.042 I/B4A (28300): ~i:** Service (s2) Start **
00:55:22.042 I/B4A (28300): ~i:** Activity (main) Pause, UserClosed = true **
How can I make my services keep alive?
That "s2" service code :
B4X:
Sub Service_Create
Timer1.Initialize("Timer1",1000)
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Sub Timer1_Tick
Dim Time_Num As Int
DateTime.DateFormat="HHmmss"
Time_Num = DateTime.Date(DateTime.now)
DateTime.DateFormat="HH:mm:ss"
If ((Time_Num > 75900) AND (Time_Num < 200000)) Then
n.SetInfo("[" & DateTime.Date(DateTime.now) & "]", "Start!", Main)
Timer1.Enabled = False
Timer2.Initialize("Timer2",2500)
Timer2.Interval = 1500
Timer2.Enabled = True
TimerN = 0
t = 0
Else
n.SetInfo("[" & DateTime.Date(DateTime.now) & "]", "It will start at 07:59", Main) 'Change Main (above) to "" if this code is in the main module.
n.Notify(1)
End If
End Sub
2, About GCM problem
After a long time, when I use gcm send something to my device, it got a error msg.
Is that gcm have a live time too ?
Or just I do something worng...
12:27:14.410 I/B4A (30218): ~e:java.lang.RuntimeException: Unable to create service com.andrewchan.smsforbotv2.pushservice: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
12:27:14.410 I/B4A (30218): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2414)
12:27:14.410 I/B4A (30218): ~e: at android.app.ActivityThread.access$1600(ActivityThread.java:140)
12:27:14.410 I/B4A (30218): ~e: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
12:27:14.410 I/B4A (30218): ~e: at android.os.Handler.dispatchMessage(Handler.java:99)
12:27:14.410 I/B4A (30218): ~e: at android.os.Looper.loop(Looper.java:137)
12:27:14.410 I/B4A (30218): ~e: at android.app.ActivityThread.main(ActivityThread.java:4898)
12:27:14.410 I/B4A (30218): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
12:27:14.410 I/B4A (30218): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
12:27:14.410 I/B4A (30218): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
12:27:14.410 I/B4A (30218): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
12:27:14.410 I/B4A (30218): ~e: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
12:27:14.410 I/B4A (30218): ~e: at dalvik.system.NativeStart.main(Native Method)
12:27:14.410 I/B4A (30218): ~e:Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
12:27:14.410 I/B4A (30218): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:33)
12:27:14.410 I/B4A (30218): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
12:27:14.410 I/B4A (30218): ~e: ... 11 more
12:27:14.410 I/B4A (30218): ~e:Caused by: java.lang.reflect.InvocationTargetException
12:27:14.410 I/B4A (30218): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
12:27:14.410 I/B4A (30218): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
12:27:14.410 I/B4A (30218): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:31)
12:27:14.410 I/B4A (30218): ~e: ... 12 more
12:27:14.410 I/B4A (30218): ~e:Caused by: java.lang.RuntimeException: java.lang.NullPointerException
12:27:14.410 I/B4A (30218): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:572)
12:27:14.410 I/B4A (30218): ~e: ... 15 more
12:27:14.410 I/B4A (30218): ~e:Caused by: java.lang.NullPointerException
12:27:14.410 I/B4A (30218): ~e: at anywheresoftware.b4a.BA.<init>(BA.java:106)
12:27:14.410 I/B4A (30218): ~e: at adr.stringfunctions.stringfunctions.innerInitialize(stringfunctions.java:12)
12:27:14.410 I/B4A (30218): ~e: at adr.stringfunctions.stringfunctions._initialize(stringfunctions.java:324)
12:27:14.410 I/B4A (30218): ~e: at com.andrewchan.smsforbotv2.main._process_globals(main.java:693)
12:27:14.410 I/B4A (30218): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:564)
12:27:14.410 I/B4A (30218): ~e: ... 15 more
12:27:50.540 I/B4A (31228): ~e:java.lang.RuntimeException: Unable to create service com.andrewchan.smsforbotv2.pushservice: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
12:27:50.540 I/B4A (31228): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2414)
12:27:50.540 I/B4A (31228): ~e: at android.app.ActivityThread.access$1600(ActivityThread.java:140)
12:27:50.540 I/B4A (31228): ~e: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
12:27:50.540 I/B4A (31228): ~e: at android.os.Handler.dispatchMessage(Handler.java:99)
12:27:50.540 I/B4A (31228): ~e: at android.os.Looper.loop(Looper.java:137)
12:27:50.540 I/B4A (31228): ~e: at android.app.ActivityThread.main(ActivityThread.java:4898)
12:27:50.540 I/B4A (31228): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
12:27:50.540 I/B4A (31228): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
12:27:50.540 I/B4A (31228): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
12:27:50.540 I/B4A (31228): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
12:27:50.540 I/B4A (31228): ~e: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
12:27:50.540 I/B4A (31228): ~e: at dalvik.system.NativeStart.main(Native Method)
12:27:50.540 I/B4A (31228): ~e:Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
12:27:50.540 I/B4A (31228): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:33)
12:27:50.540 I/B4A (31228): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
12:27:50.540 I/B4A (31228): ~e: ... 11 more
12:27:50.540 I/B4A (31228): ~e:Caused by: java.lang.reflect.InvocationTargetException
12:27:50.540 I/B4A (31228): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
12:27:50.540 I/B4A (31228): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
12:27:50.540 I/B4A (31228): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:31)
12:27:50.540 I/B4A (31228): ~e: ... 12 more
12:27:50.540 I/B4A (31228): ~e:Caused by: java.lang.RuntimeException: java.lang.NullPointerException
12:27:50.540 I/B4A (31228): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:572)
12:27:50.540 I/B4A (31228): ~e: ... 15 more
12:27:50.540 I/B4A (31228): ~e:Caused by: java.lang.NullPointerException
12:27:50.540 I/B4A (31228): ~e: at anywheresoftware.b4a.BA.<init>(BA.java:106)
12:27:50.540 I/B4A (31228): ~e: at adr.stringfunctions.stringfunctions.innerInitialize(stringfunctions.java:12)
12:27:50.540 I/B4A (31228): ~e: at adr.stringfunctions.stringfunctions._initialize(stringfunctions.java:324)
12:27:50.540 I/B4A (31228): ~e: at com.andrewchan.smsforbotv2.main._process_globals(main.java:693)
12:27:50.540 I/B4A (31228): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:564)
12:27:50.540 I/B4A (31228): ~e: ... 15 more
13:48:08.370 I/B4A (30067): ~e:java.lang.RuntimeException: Unable to create service com.andrewchan.smsforbotv2.pushservice: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
13:48:08.370 I/B4A (30067): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2414)
13:48:08.370 I/B4A (30067): ~e: at android.app.ActivityThread.access$1600(ActivityThread.java:140)
13:48:08.370 I/B4A (30067): ~e: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
13:48:08.370 I/B4A (30067): ~e: at android.os.Handler.dispatchMessage(Handler.java:99)
13:48:08.370 I/B4A (30067): ~e: at android.os.Looper.loop(Looper.java:137)
13:48:08.370 I/B4A (30067): ~e: at android.app.ActivityThread.main(ActivityThread.java:4898)
13:48:08.370 I/B4A (30067): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
13:48:08.370 I/B4A (30067): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
13:48:08.370 I/B4A (30067): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
13:48:08.370 I/B4A (30067): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
13:48:08.370 I/B4A (30067): ~e: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
13:48:08.370 I/B4A (30067): ~e: at dalvik.system.NativeStart.main(Native Method)
13:48:08.370 I/B4A (30067): ~e:Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
13:48:08.370 I/B4A (30067): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:33)
13:48:08.370 I/B4A (30067): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
13:48:08.370 I/B4A (30067): ~e: ... 11 more
13:48:08.370 I/B4A (30067): ~e:Caused by: java.lang.reflect.InvocationTargetException
13:48:08.370 I/B4A (30067): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
13:48:08.370 I/B4A (30067): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
13:48:08.370 I/B4A (30067): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:31)
13:48:08.370 I/B4A (30067): ~e: ... 12 more
13:48:08.370 I/B4A (30067): ~e:Caused by: java.lang.RuntimeException: java.lang.NullPointerException
13:48:08.370 I/B4A (30067): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:572)
13:48:08.370 I/B4A (30067): ~e: ... 15 more
13:48:08.370 I/B4A (30067): ~e:Caused by: java.lang.NullPointerException
13:48:08.370 I/B4A (30067): ~e: at anywheresoftware.b4a.BA.<init>(BA.java:106)
13:48:08.370 I/B4A (30067): ~e: at adr.stringfunctions.stringfunctions.innerInitialize(stringfunctions.java:12)
13:48:08.370 I/B4A (30067): ~e: at adr.stringfunctions.stringfunctions._initialize(stringfunctions.java:324)
13:48:08.370 I/B4A (30067): ~e: at com.andrewchan.smsforbotv2.main._process_globals(main.java:693)
13:48:08.370 I/B4A (30067): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:564)
13:48:08.370 I/B4A (30067): ~e: ... 15 more
13:48:42.185 I/B4A (30440): ~e:java.lang.RuntimeException: Unable to create service com.andrewchan.smsforbotv2.pushservice: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
13:48:42.185 I/B4A (30440): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2414)
13:48:42.185 I/B4A (30440): ~e: at android.app.ActivityThread.access$1600(ActivityThread.java:140)
13:48:42.185 I/B4A (30440): ~e: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
13:48:42.185 I/B4A (30440): ~e: at android.os.Handler.dispatchMessage(Handler.java:99)
13:48:42.185 I/B4A (30440): ~e: at android.os.Looper.loop(Looper.java:137)
13:48:42.185 I/B4A (30440): ~e: at android.app.ActivityThread.main(ActivityThread.java:4898)
13:48:42.185 I/B4A (30440): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
13:48:42.185 I/B4A (30440): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
13:48:42.185 I/B4A (30440): ~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
13:48:42.185 I/B4A (30440): ~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
13:48:42.185 I/B4A (30440): ~e: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:106)
13:48:42.185 I/B4A (30440): ~e: at dalvik.system.NativeStart.main(Native Method)
13:48:42.185 I/B4A (30440): ~e:Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
13:48:42.185 I/B4A (30440): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:33)
13:48:42.185 I/B4A (30440): ~e: at android.app.ActivityThread.handleCreateService(ActivityThread.java:2404)
13:48:42.185 I/B4A (30440): ~e: ... 11 more
13:48:42.185 I/B4A (30440): ~e:Caused by: java.lang.reflect.InvocationTargetException
13:48:42.185 I/B4A (30440): ~e: at java.lang.reflect.Method.invokeNative(Native Method)
13:48:42.185 I/B4A (30440): ~e: at java.lang.reflect.Method.invoke(Method.java:511)
13:48:42.185 I/B4A (30440): ~e: at com.andrewchan.smsforbotv2.pushservice.onCreate(pushservice.java:31)
13:48:42.185 I/B4A (30440): ~e: ... 12 more
13:48:42.185 I/B4A (30440): ~e:Caused by: java.lang.RuntimeException: java.lang.NullPointerException
13:48:42.185 I/B4A (30440): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:572)
13:48:42.185 I/B4A (30440): ~e: ... 15 more
13:48:42.185 I/B4A (30440): ~e:Caused by: java.lang.NullPointerException
13:48:42.185 I/B4A (30440): ~e: at anywheresoftware.b4a.BA.<init>(BA.java:106)
13:48:42.185 I/B4A (30440): ~e: at adr.stringfunctions.stringfunctions.innerInitialize(stringfunctions.java:12)
13:48:42.185 I/B4A (30440): ~e: at adr.stringfunctions.stringfunctions._initialize(stringfunctions.java:324)
13:48:42.185 I/B4A (30440): ~e: at com.andrewchan.smsforbotv2.main._process_globals(main.java:693)
13:48:42.185 I/B4A (30440): ~e: at com.andrewchan.smsforbotv2.main.initializeProcessGlobals(main.java:564)
13:48:42.185 I/B4A (30440): ~e: ... 15 more
3, I've write a function in GCM service ( MessageArrived ) to call a service.
B4X:
If Intent.HasExtra("data") Then TypeN = Intent.GetExtra("type")
If TypeN = "3" Then
StopService(s1)
StartService(s2)
CallSubDelayed(s2,"ReStart")
ToastMessageShow("Start Services", True)
Return
Else If TypeN = "4" Then
ToastMessageShow("Kill Services", True)
s2.Timer2.Enabled = False
StopService(s2)
StopService(s1)
Return
End If
The service is start properly,
But in type = 4,
The service will restart sometimes, and sometimes can stop properly. -_-!!!
Log :
1, type 3 -> It started.14:02:24.675 I/B4A ( 2896): ~i:** Activity (main) Create, isFirst = true **
14:02:24.885 I/B4A ( 2896): ~i:** Activity (main) Resume **
14:02:24.930 I/B4A ( 2896): ~i:** Service (s1) Create **
14:02:24.930 I/B4A ( 2896): ~i:** Service (s1) Start **
14:02:25.085 I/B4A ( 2896): ~i:** Service (pushservice) Create **
14:02:25.085 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:02:26.400 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:02:26.430 I/B4A ( 2896): ~i:** Service (httputils2service) Create **
14:02:26.430 I/B4A ( 2896): ~i:** Service (httputils2service) Start **
14:02:30.305 I/B4A ( 2896): ~i:** Activity (main) Pause, UserClosed = false **
14:02:30.345 I/B4A ( 2896): ~i:** Service (s1) Destroy **
14:02:47.380 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:02:47.380 I/B4A ( 2896): New command: 3
14:02:47.410 I/B4A ( 2896): ~i:** Service (s2) Create **
14:02:47.415 I/B4A ( 2896): ~i:** Service (s2) Start **
14:03:03.660 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:03.660 I/B4A ( 2896): New command: 4
14:03:03.670 I/B4A ( 2896): ~i:** Service (s2) Destroy **
14:03:15.040 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:15.040 I/B4A ( 2896): New command: 3
14:03:15.085 I/B4A ( 2896): ~i:** Service (s2) Create **
14:03:15.095 I/B4A ( 2896): ~i:** Service (s2) Start **
14:03:20.345 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:20.345 I/B4A ( 2896): New command: 4
14:03:20.360 I/B4A ( 2896): ~i:** Service (s2) Destroy **
14:03:28.510 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:28.515 I/B4A ( 2896): New command: 3
14:03:28.560 I/B4A ( 2896): ~i:** Service (s2) Create **
14:03:28.565 I/B4A ( 2896): ~i:** Service (s2) Start **
14:03:35.055 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:35.055 I/B4A ( 2896): New command: 4
14:03:35.070 I/B4A ( 2896): ~i:** Service (s2) Destroy **
14:03:36.100 I/B4A ( 2896): ~i:** Service (s2) Create **
14:03:36.105 I/B4A ( 2896): ~i:** Service (s2) Start **
14:03:47.680 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:03:47.680 I/B4A ( 2896): New command: 4
14:03:47.695 I/B4A ( 2896): ~i:** Service (s2) Destroy **
14:03:49.645 I/B4A ( 2896): ~i:** Service (s2) Create **
14:03:49.655 I/B4A ( 2896): ~i:** Service (s2) Start **
14:04:05.015 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:04:05.015 I/B4A ( 2896): New command: 4
14:04:05.220 I/B4A ( 2896): ~i:** Service (s2) Destroy **
14:04:05.805 I/B4A ( 2896): ~i:** Service (s2) Create **
14:04:05.810 I/B4A ( 2896): ~i:** Service (s2) Start **
14:04:10.955 I/B4A ( 2896): ~i:** Service (pushservice) Start **
14:04:10.955 I/B4A ( 2896): New command: 4
14:04:10.965 I/B4A ( 2896): ~i:** Service (s2) Destroy **
2, type 4 -> It stoped.
3, type 3 -> It started.
4, type 4 -> It stoped.
5, type 3 -> It started.
6, type 4 -> It restarted !!!!!!
7, type 4 -> It restarted !!!!!!
8, type 4 -> It restarted !!!!!!
9, type 4 -> Finally, It know stoped.
4, Fromula problem
4.1, I dim a (NBnum as Int) in (Process_Globals), then I make it when messagearrived one time, it will add 1 it self.
But it didn't, is it because everytimes when GCM coming it will start the services again, so the NBnum will always keep at 10 ?
If is that, can I temp a var in GCM services? or do I need to put NBnum = 10 in (Process_Globals) ? Is there is the right way to do that?
4.2,
"If Line1.Length > 0 Then" this not working - -!
And I've try "If Line1 = "" Then",
is also not working.
It don't care Line1 this var have / don't have value,
And it will do inside if : "nbInboxStyle.AddLine = Line1"
B4X:
Sub Service_Start (StartingIntent As Intent)
NBnum = 10
End Sub
Sub MessageArrived (Intent As Intent)
If TypeN = "2" Then
NBnum = NBnum + 1
nb.OnGoingEvent = False
nbInboxStyle.BigContentTitle = Title
nbInboxStyle.SummaryText = Summary
If Line1.Length > 0 Then
nbInboxStyle.AddLine = Line1
End If
If Line2.Length > 0 Then
nbInboxStyle.AddLine = Line2
End If
If Line3.Length > 0 Then
nbInboxStyle.AddLine = Line3
End If
If Line4.Length > 0 Then
nbInboxStyle.AddLine = Line4
End If
If Line5.Length > 0 Then
nbInboxStyle.AddLine = Line5
End If
nb.SetStyle(nbInboxStyle)
nb.Notify(NBnum)
End If
End Sub
5, Mainfest Problem
I've using Receive SMS method
B4X:
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(s1,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
AddReceiverText(s2,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
If s2 is active, just s1 have action.
If s1 is active, just s2 have action.
Doing like this ?
P.S. I attatched my full app source code.
Attachments
Last edited: