سؤال

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