Skip to content Skip to sidebar Skip to footer

Android Getsystemservice Error With Extends Broadcastreceiver

I have 2 activities public class MainActivity extends AppCompatActivity { .............. @Override protected void onCreate(Bundle savedInstanceState) { ...........

Solution 1:

getSystemService() is a method on Context. BroadcastReceiver does not inherit from Context. However, you are passed a Context into onReceive(). So, call getSystemService() on that Context parameter.

Solution 2:

Since you are passing context in onReceive() method just call it using that context like

context.getSystemService(Context.TELEPHONY_SERVICE);

Post a Comment for "Android Getsystemservice Error With Extends Broadcastreceiver"