I want to use BroadcastReceiver inside SystemSensorManager class (android.hardware). I managed to define an object of type BroadcastReceiver but when I tried to register this receiver using :

registerReceiver(BroadcastReceiver receiver, IntentFilter filter) 

This method cannot be found and the source code doesnt compile.

I tried the to do similar thing in the Activity class and it succeeded. whats wrong with the SystemSensorManager class ?

有帮助吗?

解决方案

registerReceiver is defined on Context and its descendants. SystemSensorManager receives context in constructor, but does not remember it. You should find a relevant Context for your change.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top