3

I'm running the Google Codelab Android Activity Recognition API example on my Samsung 8+ https://codelabs.developers.google.com/codelabs/activity-recognition-transition/

And although the example starts fine on my phone, I do not get any events from the activity recognition API. I first though that it might be a permission issue, but On Android 9 I could not find a permission setting for the ACTIVITY_RECOGNITION, this seems to be necessary for Android 10 onwards.

Could someone give a pointer what possible reasons might be that my Samsung 8+ is not getting any Activity Recognition events?

Michael Rumpf
  • 371
  • 1
  • 5
  • 9

2 Answers2

2

I have 2 Xiaomi phone that is running Android 9. 1 is Redmi Note 3 and is working . The other 1 is Pocophone and it is not working.

Then I tested with Samsung Galaxy Grand Prime Android 5. It is working. Now I am confused why some device it appears but some not appear.

  • I have tested this thing on many devices, Working fine in Xiaomi, Poco, Pixel phones, but sadly not working in Samsung(one high-end, one low-end) devices. – Anshul1507 Jun 28 '23 at 10:55
1

Even registering broadcast receiver in Manifest file,you need to register in dynamically in Oreo+ otherwise it will not work. Try this.Add this code in main activity or in startCommand in Service.It worked for me.I have tested this code on Android 10 too..worked perfectly.You dont need to register broadcast receiver in Manifest.

@Override
    protected void onStart() {
        super.onStart();
        IntentFilter intentFilter=new IntentFilter(Constants.BROADCAST_DETECTED_ACTIVITY);
    intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
        registerReceiver(broadcastReceiver,intentFilter);

    }
jyotsna
  • 97
  • 1
  • 9
  • So wait, I'm a lil bit confused, I registered my broadcast in the manifest + dynamically in code, is that okay? will it make things x2 or something ? – David.C Aug 01 '21 at 07:04