List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java
public void onResume() { if (debugUsbComm) { logString = TAG + ": onResume"; Log.d(TAG, logString);/*from w ww . j av a 2 s . com*/ appendLog("debugUsbComm.txt", logString, false); } super.onResume(); // when FrontImageActivity is started and the back button is pressed then this "onResume" // is called again and we don't want to restart twice the communication. Basically only at the // first call to "onStart" we start the USB communication. if (!frontImageActivityStarted) { wheelphone.startUSBCommunication(); } // Determines if user is connected to a wireless network & displays ip if (!streaming) displayIpAddress(); startServers(); registerReceiver(wifiStateReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION)); // QCAR-specific resume operation: QCAR.onResume(); // We may start the camera only if the QCAR SDK has already been // initialized: if (mAppStatus == APPSTATUS_CAMERA_STOPPED) { updateApplicationStatus(APPSTATUS_CAMERA_RUNNING); } }
From source file:edu.stanford.mobisocial.dungbeetle.NearbyActivity.java
private void findBluetooth() { if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) { Intent bt = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(bt, RESULT_BT_ENABLE); return;//from ww w . j a v a 2 s . c om } // Create a BroadcastReceiver for ACTION_FOUND final IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); final BroadcastReceiver receiver = new BroadcastReceiver() { public void onReceive(final Context context, final Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { new Thread() { public void run() { BluetoothBeacon.OnDiscovered discovered = new BluetoothBeacon.OnDiscovered() { @Override public void onDiscovered(final byte[] data) { runOnUiThread(new Runnable() { @Override public void run() { try { JSONObject obj = new JSONObject(new String(data)); mNearbyList.add( new NearbyItem(NearbyItem.Type.FEED, obj.getString("name"), Uri.parse(obj.getString("dynuri")), null)); mAdapter.notifyDataSetChanged(); } catch (JSONException e) { Log.e(TAG, "Error getting group info over bluetooth", e); } } }); } }; // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); BluetoothBeacon.discover(NearbyActivity.this, device, discovered); }; }.start(); } if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { unregisterReceiver(this); } } }; registerReceiver(receiver, filter); // Don't forget to unregister during // onDestroy BluetoothAdapter.getDefaultAdapter().startDiscovery(); Toast.makeText(this, "Scanning Bluetooth...", 500).show(); }
From source file:co.beem.project.beem.FbTextService.java
/** * {@inheritDoc}//www. jav a2s . c om */ @Override public void onCreate() { super.onCreate(); Utils.setContext(getApplicationContext()); smackAndroid = SmackAndroid.init(FbTextService.this); StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); savingMessageQueue = new LinkedBlockingQueue<co.beem.project.beem.service.BeemMessage>(); stateChangeQueue = new LinkedBlockingQueue<User>(); sendImageQueue = new LinkedBlockingDeque<ImageMessageInQueue>(); isRunning = true; sessionManager = new SessionManager(FbTextService.this); savingMessageOnBackgroundThread(new SavingNewMessageTask()); savingMessageOnBackgroundThread(new UpdateUserStateTask()); savingMessageOnBackgroundThread(new SendImageTask()); handler = new Handler(); registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTED)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTING)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_DISCONNECT)); this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CONNECTING_In)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.SEND_IMAGE_MESSAGE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.SEND_INVITATION)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.UPDATE_USER_STATE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.PUSH_NOTIFICATION_FAVORITE_ONLINE)); registerReceiver(mOnOffReceiver, new IntentFilter(FbTextApplication.CHANGE_STATUS)); mSettings = PreferenceManager.getDefaultSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener); if (mSettings.getBoolean(FbTextApplication.USE_AUTO_AWAY_KEY, false)) { mOnOffReceiverIsRegistered = true; registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF)); registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON)); // registerReceiver(sma, filter) } String tmpJid = mSettings.getString(FbTextApplication.ACCOUNT_USERNAME_KEY, "").trim(); mLogin = StringUtils.parseName(tmpJid); boolean useSystemAccount = mSettings.getBoolean(FbTextApplication.USE_SYSTEM_ACCOUNT_KEY, false); mPort = DEFAULT_XMPP_PORT; mService = StringUtils.parseServer(tmpJid); mHost = mService; initMemorizingTrustManager(); if (mSettings.getBoolean(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) { mHost = mSettings.getString(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "").trim(); if ("".equals(mHost)) mHost = mService; String tmpPort = mSettings.getString(FbTextApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222"); if (!"".equals(tmpPort)) mPort = Integer.parseInt(tmpPort); } if (mSettings.getBoolean(FbTextApplication.FULL_JID_LOGIN_KEY, false) || "gmail.com".equals(mService) || "googlemail.com".equals(mService) || useSystemAccount) { mLogin = tmpJid; } configure(ProviderManager.getInstance()); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Roster.setDefaultSubscriptionMode(SubscriptionMode.manual); mBind = new XmppFacade(this); if (FbTextApplication.isDebug) Log.d(TAG, "Create FacebookTextService \t id: " + mLogin + " \t host: " + mHost + "\tmPort" + mPort + "\t service" + mService); }
From source file:com.openerp.addons.messages.Message.java
@Override public void onResume() { super.onResume(); scope.context().registerReceiver(messageSyncFinish, new IntentFilter(SyncFinishReceiver.SYNC_FINISH)); scope.context().registerReceiver(datasetChangeReceiver, new IntentFilter(DataSetChangeReceiver.DATA_CHANGED)); }
From source file:org.metawatch.manager.Monitors.java
private static void createBatteryLevelReciever(Context context) { if (batteryLevelReceiver != null) return;/* w w w. j a v a2 s . c om*/ batteryLevelReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); int level = -1; if (rawlevel >= 0 && scale > 0) { level = (rawlevel * 100) / scale; } boolean charging = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) > 0; if (BatteryData.level != level || BatteryData.charging != charging) { //if (Preferences.logging) Log.d(MetaWatch.TAG, "Battery level changed: "+rawlevel+"/"+scale+" - "+level+"%"); BatteryData.level = level; BatteryData.charging = charging; Idle.updateIdle(context, true); } } }; context.registerReceiver(batteryLevelReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); }
From source file:bf.io.openshop.ux.MainActivity.java
@Override protected void onResume() { super.onResume(); // FB base events logging AppEventsLogger.activateApp(this); // GCM registration LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver, new IntentFilter(SettingsMy.REGISTRATION_COMPLETE)); }
From source file:com.kncwallet.wallet.ui.WalletActivity.java
private void checkLowStorageAlert() { final Intent stickyIntent = registerReceiver(null, new IntentFilter(Intent.ACTION_DEVICE_STORAGE_LOW)); if (stickyIntent != null) { final KnCDialog.Builder builder = new KnCDialog.Builder(this); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setTitle(R.string.wallet_low_storage_dialog_title); builder.setMessage(R.string.wallet_low_storage_dialog_msg); builder.setPositiveButton(R.string.wallet_low_storage_dialog_button_apps, new DialogInterface.OnClickListener() { @Override//from ww w .j a va 2 s .c om public void onClick(final DialogInterface dialog, final int id) { startActivity( new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS)); finish(); } }); builder.setNegativeButton(R.string.button_dismiss, null); builder.show(); } }
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
private void enableTagWriteMode() { Log.d("TAG_VIEWER", "in enable tag write"); mWriteMode = true;/*from www .j a v a 2 s. c o m*/ IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); // tagDetected.addDataScheme("http"); // IntentFilter techFilter = new // IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); try { tagDetected.addDataType("text/plain"); // tagDetected.addDataScheme("http"); // techFilter.addDataType("text/plain"); } catch (MalformedMimeTypeException e) { // TODO Auto-generated catch block e.printStackTrace(); } IntentFilter httpDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); httpDetected.addDataScheme("http"); mWriteTagFilters = new IntentFilter[] { tagDetected, httpDetected }; mNfcAdapter.enableForegroundDispatch(this, mNfcPendingIntent, mWriteTagFilters, null); }
From source file:com.cellbots.logger.LoggerActivity.java
private void registerBattery() { IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(batteryBroadcastReceiver, batteryFilter); }
From source file:com.dsna.android.main.MainActivity.java
public void logBatteryLevelAndProcessTime(long processedTime) { IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); batteryStatus = getApplicationContext().registerReceiver(null, ifilter); int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1); float batteryPct = level / (float) scale; batteryPct = Math.max(Math.min(batteryPct, 1), 0); logBatteryAndProcessResult.append(System.currentTimeMillis()); logBatteryAndProcessResult.append(','); logBatteryAndProcessResult.append(batteryPct); logBatteryAndProcessResult.append(','); logBatteryAndProcessResult.append(processedTime); logBatteryAndProcessResult.append('\n'); }