private static final String TAG = "FENCE_RECEIVER"; @Override public void onReceive(Context context, Intent intent) { if (!TextUtils.equals("com.kgmyshin.fence.RECEIVE_FENCE", intent.getAction())) { return; } FenceState state = FenceState.extract(intent); if (TextUtils.equals(state.getFenceKey(), FenceKey.PLUG_IN.name())) { if (state.getCurrentState() == FenceState.TRUE) { Toast.makeText(context, "plug in", Toast.LENGTH_SHORT).show(); } Log.i(TAG, "FENCE_START: " + state.getCurrentState()); } } } <receiver android:name=".fence.FenceReceiver"> <intent-filter> <action android:name="com.kgmyshin.fence.RECEIVE_FENCE" /> </intent-filter> </receiver>