Android Question Activity Recognition Detection

roncoa

Member
Licensed User
Longtime User
I am trying the ActivityRecognition.zip file in this thread https://www.b4x.com/android/forum/threads/physical-activity-recognition-detection.42481/ ,but this code is never fired.
B4X:
    For Each ev As TransitionEvent In Starter.client.GetTransitionEvents(StartingIntent)
        Log(ev) 'ignore
        ToastMessageShow("" & ev, True)
    Next
    Service.StopAutomaticForeground
I am attaching an image with the log.
Is it correct that the class shows 'v1.00' and not 'v3.00'?

Thanks
 

Attachments

  • Immagine 2020-12-13 225619.png
    Immagine 2020-12-13 225619.png
    431.4 KB · Views: 647
Is it correct that the class shows 'v1.00' and not 'v3.00'?
Yes, that's the correct code.

I've just tested it on an Android 11 device and it works properly. I tested it outdoors and the detection doesn't happen immediately.

These are the logs:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (activity_permissionresult)
running waiting messages (1)
** Activity (main) Resume **
true <-------------------------------------------------------------------- do you see this one?
** Receiver (recognitionservice) OnReceive **
*** Service (recognitionservice) Create ***
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=401678140000000, IsInitialized=true
, TransitionType=EXIT]
[ActivityType=WALKING, ElapsedTime=401678140000000, IsInitialized=true
, TransitionType=ENTER]
** Receiver (recognitionservice) OnReceive **
** Service (recognitionservice) Start **
[ActivityType=WALKING, ElapsedTime=401707031000000, IsInitialized=true
, TransitionType=EXIT]
[ActivityType=STILL, ElapsedTime=401707031000000, IsInitialized=true
, TransitionType=ENTER]
 
Upvote 0
It only worked fine the first time I loaded the app with B4A.
From the second time, in the log I only see "true" without "ActivityType = ....."


B4X:
Logger connesso a:  LGE LG-H870
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Receiver (recognitionservice) OnReceive **
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=172177882000000, IsInitialized=true
, TransitionType=ENTER]
true
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Receiver (recognitionservice) OnReceive **
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=172177882000000, IsInitialized=true
, TransitionType=ENTER]
true
** Activity (main) Pause, UserClosed = false **
** Service (recognitionservice) Destroy **
** Service (starter) Destroy (ignored)**
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Receiver (recognitionservice) OnReceive **
*** Service (recognitionservice) Create ***
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=172177882000000, IsInitialized=true
, TransitionType=ENTER]
true
** Activity (main) Pause, UserClosed = true **
Logger connesso a:  LGE LG-H870
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Receiver (recognitionservice) OnReceive **
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=172177882000000, IsInitialized=true
, TransitionType=ENTER]
true
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Receiver (recognitionservice) OnReceive **
** Service (recognitionservice) Start **
[ActivityType=STILL, ElapsedTime=172177882000000, IsInitialized=true
, TransitionType=ENTER]
true
** Activity (main) Pause, UserClosed = true **


From the second upload :

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
true
** Activity (main) Pause, UserClosed = false **
** Service (starter) Destroy (ignored)**
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 
Upvote 0
I have always successfully used the old method, which allowed to set a detection interval and to have a confidence value.

How can I get these 2 features?

Possibly, is there any contraindication to using the old method?
 
Upvote 0
How can I get these 2 features?
You should first get it working.

Possibly, is there any contraindication to using the old method?
No. The old API is no longer supported.

Based on the logs, it looks like the code is correct. Make sure to test it in release mode. Try to restart the device and see if it helps.
 
Upvote 0
I got it all working, thank you very much.
I just have one more question.
How can I "force" the status update, or "reset" it in order to have the current "Recognition_state"?
For example, if I start the app and the phone is in STILL-ENTER, I will not have updates until the status changes to STILL-EXIT and then to the new status. I would like to have STILL-ENTER (or any other status) on demand.

Thanks again
 
Upvote 0
Back
Top