List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter()
From source file:com.goodhustle.ouyaunitybridge.OuyaUnityActivity.java
@Override protected void onStart() { super.onStart(); // Immediately request an up-to-date copy of receipts. requestReceipts();/* w w w.j a v a 2s .c o m*/ // Register to receive notifications about account changes. This will re-query the receipt // list in order to ensure it is always up to date for whomever is logged in. accountsChangedFilter = new IntentFilter(); accountsChangedFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION); registerReceiver(mAuthChangeReceiver, accountsChangedFilter); // listen for controller changes - http://developer.android.com/reference/android/hardware/input/InputManager.html#registerInputDeviceListener%28android.hardware.input.InputManager.InputDeviceListener,%20android.os.Handler%29 Context context = getBaseContext(); mInputManager = (InputManager) context.getSystemService(Context.INPUT_SERVICE); mInputManager.registerInputDeviceListener(this, null); sendDevices(); }
From source file:com.connectsdk.discovery.DiscoveryManager.java
private void registerBroadcastReceiver() { if (isBroadcastReceiverRegistered == false) { isBroadcastReceiverRegistered = true; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); context.registerReceiver(receiver, intentFilter); }//from ww w. j a va 2 s . co m }
From source file:com.easemob.chatuidemo.ui.MainActivity.java
private void registerBroadcastReceiver() { broadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED); intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED); broadcastReceiver = new BroadcastReceiver() { @Override//from w w w . j av a2s . c o m public void onReceive(Context context, Intent intent) { updateUnreadLabel(); updateUnreadAddressLable(); if (currentTabIndex == 0) { // ?????? if (conversationListFragment != null) { conversationListFragment.refresh(); } } else if (currentTabIndex == 1) { if (contactListFragment != null) { contactListFragment.refresh(); } } String action = intent.getAction(); if (action.equals(Constant.ACTION_GROUP_CHANAGED)) { if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) { GroupsActivity.instance.onResume(); } } } }; broadcastManager.registerReceiver(broadcastReceiver, intentFilter); }
From source file:com.yattatech.dbtc.activity.MainScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout_main_screen); final int color = getResources().getColor(R.color.grey2); final ActionBar actionBar = getActionBar(); mFilter = new IntentFilter(); mLocaleChangedFilter = new IntentFilter(); mTaskList = (DragSortListView) findViewById(R.id.taskList); mTaskListAdapter = new TaskListAdapter(this); final String appKey = getString(R.string.dropbox_key); final String appSecret = getString(R.string.dropbox_secret); final AppKeyPair pair = new AppKeyPair(appKey, appSecret); final AndroidAuthSession session = new AndroidAuthSession(pair); mDropboxAPI = new DropboxAPI<AndroidAuthSession>(session); mToken = FACADE.getDropBoxToken();//w w w . j av a 2 s. co m mTaskList.setAdapter(mTaskListAdapter); mTaskList.setOnItemClickListener(mTaskListListener); mTaskList.setDropListener(mDropListener); mTaskList.setDragScrollProfile(mScrollProfile); mTaskList.setFloatViewManager(new MainViewManager(mTaskList)); mFilter.addAction(ADD_NEW_TASK_ACTION); mFilter.addAction(EDIT_TASK_ACTION); mFilter.addAction(REMOVE_TASK_ACTION); mFilter.addAction(BACKUP_RESTORE_ACTION); mLocaleChangedFilter.addAction(Intent.ACTION_LOCALE_CHANGED); actionBar.setIcon(R.drawable.ic_task); actionBar.setTitle(R.string.app_name); actionBar.setBackgroundDrawable(new ColorDrawable(color)); Broadcaster.registerLocalReceiver(mReceiver, mFilter); registerReceiver(mLocaleChangedReceiver, mLocaleChangedFilter); registerForContextMenu(mTaskList); final List<Task> tasks = FACADE.getTasks(); mTaskListAdapter.setElements(FACADE.restoreDataOrder(tasks)); }
From source file:com.facebook.internal.LikeActionController.java
private static void registerSessionBroadcastReceivers() { LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(applicationContext); IntentFilter filter = new IntentFilter(); filter.addAction(Session.ACTION_ACTIVE_SESSION_UNSET); filter.addAction(Session.ACTION_ACTIVE_SESSION_CLOSED); filter.addAction(Session.ACTION_ACTIVE_SESSION_OPENED); broadcastManager.registerReceiver(new BroadcastReceiver() { @Override/* w w w.j av a2s .c o m*/ public void onReceive(Context receiverContext, Intent intent) { if (isPendingBroadcastReset) { return; } String action = intent.getAction(); final boolean shouldClearDisk = Utility.areObjectsEqual(Session.ACTION_ACTIVE_SESSION_UNSET, action) || Utility.areObjectsEqual(Session.ACTION_ACTIVE_SESSION_CLOSED, action); isPendingBroadcastReset = true; // Delaying sending the broadcast to reset, because we might get many successive calls from Session // (to UNSET, SET & OPEN) and a delay would prevent excessive chatter. handler.postDelayed(new Runnable() { @Override public void run() { // Bump up the objectSuffix so that we don't have a filename collision between a cache-clear and // and a cache-read/write. // // NOTE: We know that onReceive() was called on the main thread. This means that even this code // is running on the main thread, and therefore, there aren't synchronization issues with // incrementing the objectSuffix and clearing the caches here. if (shouldClearDisk) { objectSuffix = (objectSuffix + 1) % MAX_OBJECT_SUFFIX; applicationContext .getSharedPreferences(LIKE_ACTION_CONTROLLER_STORE, Context.MODE_PRIVATE).edit() .putInt(LIKE_ACTION_CONTROLLER_STORE_OBJECT_SUFFIX_KEY, objectSuffix).apply(); // Only clearing the actual caches. The MRU index will self-clean with usage. // Clearing the caches is necessary to prevent leaking like-state across sessions. cache.clear(); controllerDiskCache.clearCache(); } broadcastAction(null, ACTION_LIKE_ACTION_CONTROLLER_DID_RESET); isPendingBroadcastReset = false; } }, 100); } }, filter); }
From source file:com.iss.android.wearable.datalayer.MainActivity.java
private void RegisterBroadcastsReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(SensorsDataService.ACTION_BATTERY_STATUS); filter.addAction(SensorsDataService.ACTION_HR); filter.addAction(SensorsDataService.NEW_MESSAGE_AVAILABLE); filter.addAction(SensorsDataService.ASK_USER_FOR_RPE); filter.addAction(SensorsDataService.UPDATE_TIMER_VALUE); filter.addAction(SensorsDataService.UPDATE_GPS_PARAMS); filter.addCategory(Intent.CATEGORY_DEFAULT); registerReceiver(br, filter);/* ww w.j av a2s . c om*/ }
From source file:app.hacked.ChatFragment.java
@Override public void onResume() { super.onResume(); Log.e("onResume", "Registering broadcast"); IntentFilter filter = new IntentFilter(); filter.addAction(BROADCAST_ACTION);/* w w w . j a v a 2 s . c om*/ getActivity().registerReceiver(receiver, filter); }
From source file:com.example.android.bluetoothlegatt.DeviceControlActivity.java
public static IntentFilter getIntentFilter() { final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE_READ); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE_WRITE); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE_NOTIFY); intentFilter.addAction(CustomParsePushReceiver.ACTION_PARSE_RECEIVE); return intentFilter; }
From source file:uk.ac.ucl.excites.sapelli.relay.BackgroundService.java
/** * Register an SMS Data (Binary) Receiver *///from ww w .j av a 2 s . co m private void registerSmsReceiver() { smsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Debug.i("Received Binary SMS"); Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; if (null != bundle) { // In telecommunications the term (PDU) means protocol data // unit. // There are two ways of sending and receiving SMS messages: // by text mode and by PDU (protocol description unit) mode. // The PDU string contains not only the message, but also a // lot of meta-information about the sender, his SMS service // center, the time stamp etc // It is all in the form of hexa-decimal octets or decimal // semi-octets. Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i = 0; i < msgs.length; i++) { // Create the Message msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); // Get Message Parameters SmsObject receivedSms = new SmsObject(); receivedSms.setTelephoneNumber(msgs[i].getOriginatingAddress()); receivedSms.setMessageTimestamp(msgs[i].getTimestampMillis()); receivedSms.setMessageData(Base64.encodeToString(msgs[i].getUserData(), Base64.CRLF)); Debug.d("Received SMS and it's content hash is: " + BinaryHelpers .toHexadecimealString(Hashing.getMD5Hash(msgs[i].getUserData()).toByteArray())); // Store the SmsObject to the db dao.storeSms(receivedSms); } } // This will stop the Broadcast and not allow the message to // be interpreted by the default Android app or other apps abortBroadcast(); } }; // Set up the Receiver Parameters IntentFilter mIntentFilter = new IntentFilter(); mIntentFilter.setPriority(999); mIntentFilter.addAction("android.intent.action.DATA_SMS_RECEIVED"); mIntentFilter.addDataScheme("sms"); // Set the Port that is listening to mIntentFilter.addDataAuthority("*", "2013"); // mIntentFilter.addDataType(type) registerReceiver(smsReceiver, mIntentFilter); Debug.d("Set up BinarySMS receiver."); }