code: public static void registerReceiver(Context context, BroadcastReceiver receiver) {
          context.registerReceiver(receiver, new IntentFilter(ACTION_ACCESSORY_EVENT));
      }
docs: Register a receiver so it can receive input events.
  <p>
  You <b>must unregister the receiver</b> once you are done receiving events, otherwise a
  memory leak will occur. If you wish to register the same receiver multiple times, be sure
  to unregister it first.
  
  @param context  context in which to register for events
  @param receiver receiver to register for events