Giter Site home page Giter Site logo

codelab-activity_transitionapi's People

Contributors

codingjeremy avatar dh-- avatar osuleymanova avatar yenerm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codelab-activity_transitionapi's Issues

The Transition API is working fine on Galaxy S9 but got false positives on Pixel 5

I'm using the Transition API in a foreground service (by showing an ongoing notification) to constantly detect the user's physical activity transitions. It worked pretty well on Galaxy S9. However, when I tested the app on Pixel 5, I got multiple transitions from STILL to WALKING and WALKING to STILL even though the user was just picking up their phone and putting it back down. I was wondering if anyone encountered a similar issue. Thanks!

Application terminated or no activity reported on Android 13

I did no changes in the code, compiled, ran on Samsung with Android 13, application was terminated with following error, adding FLAG_IMMUTABLE to PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0) eliminates the exception, but no activity is reported

FATAL EXCEPTION: main
Process: com.google.example.android.basicactivityrecognitiontransitionsample, PID: 21094
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.example.android.basicactivityrecognitiontransitionsample/com.google.example.android.basicactivityrecognitiontransitionsample.MainActivity}: java.lang.IllegalArgumentException: com.google.example.android.basicactivityrecognitiontransitionsample: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

step 6. link not found

Activity Recognition Transition API Codelab
Step : 6. Review the Code
2018-06-07 1 00 14

Link > Not Found

Typo in Spet 4

Underneath the third code snippet, it says

Here we as if activity recognition is approved. If it is and activity recognition is already enabled, we disable it. Otherwise, we enable it.

Shouldn't it be?

Here we (check/verify) if activity recognition is approved. If it is and activity recognition is already enabled, we disable it. Otherwise, we enable it.

Inconsistent performance on Samsung S9 phone running Android 10

We compiled this example and it works well on a Google Pixel 2 running Android 11. We also integrated the activity transition API into our app and again, it works well on the Pixel 2. Then we started testing on a Samsung S9 and we are getting mixed results. As mentioned, we integrated the Activity Transition API into our app as well, and had both installed on the same phone for comparison. We also downloaded and installed other apps that utilize the Activity Transition API. We wanted to rule out any bugs in our code or possibly the demo code.

It was working fine for a while, then the API just suddenly stopped reporting activity transitions to all the apps. Our app creates a log for debugging and we can see our app suddenly just stops receiving activity transition updates. At the same time we checked the other apps and found the same result - all of them stopped receiving transition updates at the same time. Even after a full hard reboot of the Samsung phone, none of the apps were receiving transition updates anymore. Even tried uninstalling / reinstalling apps - no difference. All activity transitions stopped.

Then suddenly, they will start coming again. We do nothing different. All the apps registered for activity transitions suddenly started receiving them again. Then they will stop again as suddenly as they start.

We have tested with a few other phones and so far the Samsung S9+ is the only one doing this. There doesn't seem to be a pattern either. We can leave the phone sitting for hours, pick it up, and it works. We can do many transitions sequentially and it works. Then when it decides to stop working, we cannot get it working again even with a reboot. We just have to wait until it decides to work again.

Samsung Galaxy S9+
Android 10

Typo in step 5

In the Register a BroadcastReceiver for the transition section the

search for TODO: Register a BroadcastReceiver to listen for activity transitions

sentence should be replaced by

search for TODO: Register the BroadcastReceiver to listen for activity transitions

onreceive never called

no changes, only updated pending intent flags and build , its never called onreceive in API 33.

Is there a bug in samsung phone?

I am using s22, android 12.
When receive an intent ,there is extra :"com.google.android.location.internal.EXTRA_ACTIVITY_RESULT", however from the source code:
return !hasResult(var0) ? null : (ActivityTransitionResult)SafeParcelableSerializer.deserializeFromIntentExtra(var0, "com.google.android.location.internal.EXTRA_ACTIVITY_TRANSITION_RESULT", CREATOR);

It should be com.google.android.location.internal.EXTRA_ACTIVITY_TRANSITION_RESULT, so Is there a bug in samsung phone?

TransitionReceiver

TransitionReceiver is not a class that I can access when I make this variable in my own empty project (not using the codelab file). It shows highlighted read when I try to make this a variable - see pictures attached.
Screen Shot 2020-10-20 at 3 41 41 PM

I am using Android Studio version 4.0.1.

Any ideas what class I can use to replace this?

`requestActivityTransitionUpdates` throws `SecurityException` after some time and stops getting activities

Hi.
This happens after 2~3 days of using my app to track walking and running. Here is the code which is called every hour in the onStartJob of a JobService.

val request = ActivityTransitionWalkRequest.build()
val client = ActivityRecognition.getClient(appContext)
client
                .requestActivityTransitionUpdates(request, getPendingIntent(context))
                .apply {
                    addOnSuccessListener { onDone.invoke(true) }
                    addOnFailureListener { onDone.invoke(false) }
                }

I see from my logs that addOnSuccessListener is called, but also that the a SecurityException is thrown, and my BroadcastReceiver doesn't receive any transition events anymore. Here is some stacktrace:

16:51:27.602  E  Bad call made by uid 10116. Package "xxx.xxx" does not belong to uid 10283.
16:51:27.602  E  checkOperation
                 java.lang.SecurityException: Specified package "xxx.xxx" under uid 10283 but it is not
                 	at com.android.server.appop.AppOpsService.verifyAndGetBypass(AppOpsService.java:4696)
                 	at com.android.server.appop.AppOpsService.verifyAndGetBypass(AppOpsService.java:4564)
                 	at com.android.server.appop.AppOpsService.checkOperationUnchecked(AppOpsService.java:3253)
                 	at com.android.server.appop.AppOpsService.checkOperationImpl(AppOpsService.java:3236)
                 	at com.android.server.appop.AppOpsService.-$$Nest$mcheckOperationImpl(Unknown Source:0)
                 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.lambda$checkOperation$0(AppOpsService.java:7596)
                 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.$r8$lambda$KrwrxMLmGzFSEjEyo0aJ63o5J9E(Unknown Source:0)
                 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher$$ExternalSyntheticLambda9.apply(Unknown Source:24)
                 	at com.android.server.policy.AppOpsPolicy.checkOperation(AppOpsPolicy.java:213)
                 	at com.android.server.appop.AppOpsService$CheckOpsDelegateDispatcher.checkOperation(AppOpsService.java:7595)
                 	at com.android.server.appop.AppOpsService.checkOperation(AppOpsService.java:3223)
                 	at com.android.internal.app.IAppOpsService$Stub.onTransact(IAppOpsService.java:457)
                 	at android.os.Binder.execTransactInternal(Binder.java:1280)
                 	at android.os.Binder.execTransact(Binder.java:1244)

What can be the cause of this?
Thanks for any help. I can provide more source if needed.

Extra Note
in the addOnSuccessListener callback, I register a broadcast receiver like this:

unregisterReceiver(transitionsReceiver)

if (transitionsReceiver == null) {
    transitionsReceiver = ActivityTransitionReceiver()
}
registerReceiver(transitionsReceiver, IntentFilter(RECEIVER_ACTION))

Another observation: after restarting the phone, the security exception is no longer thrown and I receive transition updates.

Device / OS
Pixel 6 / Android 13

Not Working

I am using Android 9 Xiaomi but it is not working.

TransitionsReceiver Intent extras is always null

I ran the complete debug variant of the app on Galaxy Z Flip 3 5G (Android 12) and Xiaomi Redmi K40 (Android 12). After walking for a 10 metres or so, TransitionsReceiver.onReceive was called. I assume it was walking activity detected. But intent.getExtras() was null. Hence, ActivityTransitionResult.hasResult(intent) returned false, and no information was printed.

I tried 31 and 32 for targetSdkVersion and compileSdkVersion

What is the issue?

Example code not running on device

The sample app is not running on any of the Android 10 devices we tested on despite following the tutorial fully. Perhaps some permissions have changed?

ActivityTransitionAPI Pending Intent not working in background

I am trying the Activity transition API to detect the user activity, it is working fine when app is in foreground, but as soon the get closed from recent app list, the detection of Activity is stopped. The broadcast receiver is not receiving any change in activity after app close.

typo

There's the sentence "Here we as if activity recognition is approved. If it is and activity recognition is already enabled, we disable it. Otherwise, we enable it."

The word 'as' should be 'ask'.

Fatal exception

I get the following error when I try to run the codelab:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.example.android.basicactivityrecognitiontransitionsample, PID: 10099
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.example.android.basicactivityrecognitiontransitionsample/com.google.example.android.basicactivityrecognitiontransitionsample.MainActivity}: java.lang.IllegalArgumentException: com.google.example.android.basicactivityrecognitiontransitionsample: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3635)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3792)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2210)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7839)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
Caused by: java.lang.IllegalArgumentException: com.google.example.android.basicactivityrecognitiontransitionsample: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at com.google.example.android.basicactivityrecognitiontransitionsample.MainActivity.onCreate(MainActivity.java:136)
at android.app.Activity.performCreate(Activity.java:8051)
at android.app.Activity.performCreate(Activity.java:8031)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3608)
... 12 more

No activity changes detected

Hi!

I have donwloaded and executed the code you provide but no activity is being detected. Is ther a problem in the code du to recent Android updates? What can be done to have the app work as expected?

Thanks in advance for your answer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.