android / location-samples

Multiple samples showing the best practices in location APIs on Android.
Apache License 2.0
2.71k stars 2.77k forks source link

Activity Recognition - Supported devices ? #123

Open Lir10 opened 6 years ago

Lir10 commented 6 years ago

In some devices such as Huawei p8 lite and Galaxy A3 2016/2014 Activity Recognition doesn't work

is there any required hardware that needed for this API to work ?

both of the devices don't have gyro sensor

Thanks

mathieudebrito commented 6 years ago

Very interesting question, I tried the same code on an Honor 8 - does not work - and a Nexus 6 - does work - ... Is there any insight on this ?

Lir10 commented 6 years ago

@mathieudebrito As i have tested more it looks like most of the chinese phones doesn't work with this API. Any ideas?

itman85 commented 5 years ago

I used ActivityRecognitionClient to request update activity transition and receive result in pending intent broadcast receiver. It works well on nexus 6 android nougat, but on samsung note 8 Android Oreo seem does not work.

ysy950803 commented 5 years ago

I think Google doesn't test on devices plenty. Nexus and Pixel phones actually seem like no problem. But for other phones, even installed latest play service, it's not working yet.

lyseiha commented 5 years ago

i also faced that problem too on oppo F7 running andoird O, when app killed the foreground service will kill too.

mrumpf commented 4 years ago

I tried the Google codelab example on my Samsung S8+ and it does not work: https://github.com/googlecodelabs/activity_transitionapi-codelab Can someone give a pointer on how to debug this? I thought about buying another cheap Android 9 or 10 phone for development, but this ticket does not sound very promising :(

jiya4frd commented 4 years ago

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);

}
ghost commented 4 years ago

Samsung SM-A730F - android 9:🚫 not working Samsung SM-G965F - android 10:🚫 not working Samsung SM-G781U1 - android 10:🚫 not working Samsung SM-A307FN - android 10:✅ working one plus IN2011 - android 10: ✅ working

all phones have a gyroscope, accelerometer, etc.

j-shiraishi commented 3 years ago

For Huawei, we needed to add custom permissions. It worked when I added it.

<uses-permission android:name="com.huawei.hms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

https://medium.com/huawei-developers/identify-user-activities-with-hms-location-kit-in-your-xamarin-android-application-10b89c49212c

Lir10 commented 3 years ago

@j-shiraishi Interesting, I wonder why the implementation is different for Huawei devices. And if that's the case - this should be added to the Activity Recognition docs as well