List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.handpoint.headstart.client.ui.MainActivity.java
private void registerBroadcastReceivers() { IntentFilter btServiceFilter = new IntentFilter(); btServiceFilter.addAction(BROADCAST_CONNECTION_STATE_CHANGE); btServiceFilter.addAction(BROADCAST_ERROR); btServiceFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); registerReceiver(mBtServiceReceiver, btServiceFilter); }
From source file:com.darly.im.ui.LauncherActivity.java
/** * //from www. j a v a 2s . co m * * @param actionArray */ protected final void registerReceiver(String[] actionArray) { if (actionArray == null) { return; } IntentFilter intentfilter = new IntentFilter(); for (String action : actionArray) { intentfilter.addAction(action); } if (internalReceiver == null) { internalReceiver = new InternalReceiver(); } registerReceiver(internalReceiver, intentfilter); }
From source file:com.bluros.updater.UpdatesSettings.java
@Override protected void onStart() { super.onStart(); // Determine if there are any in-progress downloads mDownloadId = mPrefs.getLong(Constants.DOWNLOAD_ID, -1); if (mDownloadId >= 0) { Cursor c = mDownloadManager.query(new DownloadManager.Query().setFilterById(mDownloadId)); if (c == null || !c.moveToFirst()) { Toast.makeText(this, R.string.download_not_found, Toast.LENGTH_LONG).show(); } else {/* w w w.j a v a 2s. com*/ int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)); Uri uri = Uri.parse(c.getString(c.getColumnIndex(DownloadManager.COLUMN_URI))); if (status == DownloadManager.STATUS_PENDING || status == DownloadManager.STATUS_RUNNING || status == DownloadManager.STATUS_PAUSED) { mDownloadFileName = uri.getLastPathSegment(); } } if (c != null) { c.close(); } } if (mDownloadId < 0 || mDownloadFileName == null) { resetDownloadState(); } requestUpdateLayout(); IntentFilter filter = new IntentFilter(UpdateCheckService.ACTION_CHECK_FINISHED); filter.addAction(DownloadReceiver.ACTION_DOWNLOAD_STARTED); registerReceiver(mReceiver, filter); checkForDownloadCompleted(getIntent()); setIntent(null); }
From source file:com.example.linhdq.test.documents.creation.NewDocumentActivity.java
private synchronized void registerImageLoaderReceiver() { if (!mReceiverRegistered) { Log.i(LOG_TAG, "registerImageLoaderReceiver " + mMessageReceiver); final IntentFilter intentFilter = new IntentFilter(ImageLoadAsyncTask.ACTION_IMAGE_LOADED); intentFilter.addAction(ImageLoadAsyncTask.ACTION_IMAGE_LOADING_START); LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, intentFilter); mReceiverRegistered = true;//from w w w . j a va 2 s . c o m } }
From source file:com.googlecode.android_scripting.facade.USBHostSerialFacade.java
/** * registerIntent: from usbserialConnect {{{1 *///from w ww.j a va 2 s . c om private void registerIntent() { if (mReceiver != null) { // this function was already called. return; } Log.d("Register USB Intents..."); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); mReceiver = new USBHostSerialReceiver(); mService.registerReceiver(mReceiver, filter); }
From source file:android.support.v7.media.RemotePlaybackClient.java
/** * Creates a remote playback client for a route. * * @param route The media route./*ww w .j ava 2 s .c o m*/ */ public RemotePlaybackClient(Context context, MediaRouter.RouteInfo route) { if (context == null) { throw new IllegalArgumentException("context must not be null"); } if (route == null) { throw new IllegalArgumentException("route must not be null"); } mContext = context; mRoute = route; IntentFilter actionFilter = new IntentFilter(); actionFilter.addAction(ActionReceiver.ACTION_ITEM_STATUS_CHANGED); actionFilter.addAction(ActionReceiver.ACTION_SESSION_STATUS_CHANGED); actionFilter.addAction(ActionReceiver.ACTION_MESSAGE_RECEIVED); mActionReceiver = new ActionReceiver(); context.registerReceiver(mActionReceiver, actionFilter); Intent itemStatusIntent = new Intent(ActionReceiver.ACTION_ITEM_STATUS_CHANGED); itemStatusIntent.setPackage(context.getPackageName()); mItemStatusPendingIntent = PendingIntent.getBroadcast(context, 0, itemStatusIntent, 0); Intent sessionStatusIntent = new Intent(ActionReceiver.ACTION_SESSION_STATUS_CHANGED); sessionStatusIntent.setPackage(context.getPackageName()); mSessionStatusPendingIntent = PendingIntent.getBroadcast(context, 0, sessionStatusIntent, 0); Intent messageIntent = new Intent(ActionReceiver.ACTION_MESSAGE_RECEIVED); messageIntent.setPackage(context.getPackageName()); mMessagePendingIntent = PendingIntent.getBroadcast(context, 0, messageIntent, 0); detectFeatures(); }
From source file:com.improvelectronics.sync.android.SyncStreamingService.java
private void setupIntentFilter() { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); registerReceiver(mMessageReceiver, intentFilter); }
From source file:com.tealeaf.TeaLeaf.java
private void registerScreenOffReceiver() { if (screenOffReciever == null) { makeScreenOffReceiver();/*w w w.j a v a 2 s . co m*/ } IntentFilter filter = new IntentFilter(); filter.addAction("android.intent.action.SCREEN_OFF"); registerReceiver(screenOffReciever, filter); }
From source file:se.lu.nateko.edca.svc.GeoHelper.java
/** * Start to listen for changes in the storage state, * and report any changes to handleStorageChange. *///from ww w . ja va2s. c om private void startWatchingExternalStorage() { Log.d(TAG, "startWatchingExternalStorage() called."); mExternalStorageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.i("TAG", "Storage state changed: " + intent.getData()); updateExternalStorageState(); handleStorageChange(); } }; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_MOUNTED); filter.addAction(Intent.ACTION_MEDIA_REMOVED); mService.registerReceiver(mExternalStorageReceiver, filter); updateExternalStorageState(); }
From source file:com.bt.download.android.gui.activities.AudioPlayerActivity.java
/** * {@inheritDoc}//from w ww .j a v a 2 s.c om */ @Override protected void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(); // Play and pause changes filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED); // Shuffle and repeat changes filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED); filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED); // Track changes filter.addAction(MusicPlaybackService.META_CHANGED); // Update a list, probably the playlist fragment's filter.addAction(MusicPlaybackService.REFRESH); registerReceiver(mPlaybackStatus, filter); // Refresh the current time final long next = refreshCurrentTime(); queueNextRefresh(next); MusicUtils.notifyForegroundStateChanged(this, true); }