Receiver as inner class in Android

前端 未结 6 1711
广开言路
广开言路 2020-11-27 06:14

In my code there is an inner class that extends BroadcastReceiver.

And I have added the following line to the AndroidManifest.xml:

6条回答
  •  醉酒成梦
    2020-11-27 06:27

    This is what worked for me:

    public class OuterClass {
        public static class InnerStaticClass extends BroadcastReceiver {
            @Override
            public void onReceive(final Context context, final Intent intent) {
                final Location location = (Location) intent.getExtras().get(LocationClient.KEY_LOCATION_CHANGED);
            }
        }
    }
    

    AndroidManifest.xml:

        
    

提交回复
热议问题