2

When i was trying to developing GPS tracking Android APP with Google Activity Recognition Transition API, I had a API-working stop issue.

I thought that it is a problem of device-model compatible but not sure exactly about it because it occurs very irregulary and dose not process any error log for it.

If someone has know about the solution, please give me some good advise for it.

I really appreciate for hearing some good advise to solve this problem.

  1. Android device information:

    SDK_INT : 31

    RELEASE : 12

    BRAND : samsung

  2. An explanation for when not working Transition API:

First of all, Transition API is working good under to device model ‘Android 12’.

But when I try to test on 12 or over version, the API-stoping problem is occurs in 1 days to 1 week.

Also the problem dose not make any error log to find and analysis the exact problem.

Stoped Google Activity Recognition Transition API will work when reboots the device, but not work with re-installation.

Other APP that using Transition API having no problem while my APP is not working.

Also, other APP and my APP can be not working when the Transition API is stopped.

3.Installation in test-phone

  1. Build the Apk or generate a Signed Build generate Signed Build or Apk and upload the

  2. The same problem has occurred when try to test with the uploaded internal version of google ‘Play Store’

4.Sorce explanation

My app has one foregound service is runing.

When the APP is executed first time, the Transition API is runing that insideof the foreground service.

How to activate the API:


val intent = Intent(ACTIVITY_RECOGNITION_EVENT)
val pendingIntent = PendingIntent.getBroadcast(context, 0, intent, if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
    PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
} else {
    PendingIntent.FLAG_UPDATE_CURRENT
})

... 

val activityRecognitionClient = ActivityRecognition.getClient(context)
// val interval = 20 * 1000L
val interval = 3 * 60 * 1000L
val task = activityRecognitionClient.requestActivityUpdates(interval, pendingIntent)
task.addOnSuccessListener {
    ...
}
task.addOnCompleteListener {
    ...
}
task.addOnCanceledListener {
    ...
}
task.addOnFailureListener {
    ...
}

// createRequest skip

val activityRecognitionClient = ActivityRecognition.getClient(context)
val task = activityRecognitionClient.requestActivityTransitionUpdates(
    createRequest(),
    pendingIntent
)
task.addOnSuccessListener {
    ...
}
task.addOnCanceledListener {
    ...
}
task.addOnFailureListener {
    ...
}
task.addOnCompleteListener {
    ...
}

// In receiver, it work like this:
private val transitionsReceiver = object: BroadcastReceiver() {
    override fun onReceive(_context: Context, intent: Intent) {
        if (ActivityRecognitionResult.hasResult(intent)) {
            val result = ActivityRecognitionResult.extractResult(intent)
            ...
        }
        else if (ActivityTransitionResult.hasResult(intent)) {
            val result = ActivityTransitionResult.extractResult(intent)
            ...
        }
    }
}

val intentFilter = IntentFilter()
intentFilter.addAction(ACTIVITY_RECOGNITION_EVENT)
context.registerReceiver(transitionsReceiver, intentFilter)

Is there any one having this problem?

I’m still working on this problem but can not find the reason of the Google Activity Recognition Transition API stopping.

I would like to know any advice or hint for solving this and appreciate it for your comment.

Am I miss something or having wrong point?

barunsoft
  • 21
  • 2

2 Answers2

1

I'm having the same issue as you. It happens on both Sampling API and Transition API. We noticed on multiple Samsung devices but not sure if it is happening on other. I opened a issue on tracker

0

I'm having a similar issue. Currently what I've found is that when my app can retrieve Sensor.TYPE_SIGNIFICANT_MOTION then Activity Transitions updates come in correctly, but then at some point, sensor is null in my logs and I receive no updates whatsoever. Feels to me that OS blocks this sensor at some point (allows it to fall in deep sleep) and then there's no coming back. :(

MaaAn13
  • 264
  • 5
  • 24
  • 54