Вопрос

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