List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:air.com.snagfilms.cast.chromecast.notifications.VideoCastNotificationService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate()"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); mBroadcastReceiver = new BroadcastReceiver() { @Override/* w ww . ja va 2 s . c om*/ public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive(): " + intent.getAction()); } }; registerReceiver(mBroadcastReceiver, filter); readPersistedData(); mCastManager = VideoChromeCastManager.initialize(this, mApplicationId, mTargetActivity, null); if (!mCastManager.isConnected()) { mCastManager.reconnectSessionIfPossible(this, false); } mConsumer = new VideoCastConsumerImpl() { @Override public void onApplicationDisconnected(int errorCode) { Log.d(TAG, "onApplicationDisconnected() was reached"); stopSelf(); } @Override public void onRemoteMediaPlayerStatusUpdated() { int mediaStatus = mCastManager.getPlaybackStatus(); VideoCastNotificationService.this.onRemoteMediaPlayerStatusUpdated(mediaStatus); } }; mCastManager.addVideoCastConsumer(mConsumer); }
From source file:be.ppareit.swiftp.gui.PreferenceFragment.java
@Override public void onResume() { super.onResume(); updateRunningState();//w ww . jav a2 s . c o m Cat.d("onResume: Register the preference change listner"); SharedPreferences sp = getPreferenceScreen().getSharedPreferences(); sp.registerOnSharedPreferenceChangeListener(this); Cat.d("onResume: Registering the FTP server actions"); IntentFilter filter = new IntentFilter(); filter.addAction(FsService.ACTION_STARTED); filter.addAction(FsService.ACTION_STOPPED); filter.addAction(FsService.ACTION_FAILEDTOSTART); getActivity().registerReceiver(mFsActionsReceiver, filter); }
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//from www. j av a2 s .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.google.android.apps.iosched2.ui.ScheduleFragment.java
@Override public void onResume() { super.onResume(); SetupHelper.loadCurrentSetup(getActivity()); // Since we build our views manually instead of using an adapter, we // need to manually requery every time launched. requery();/*from w w w . j a va2 s . c o m*/ getActivity().getContentResolver().registerContentObserver(ScheduleContract.Sessions.CONTENT_URI, true, mSessionChangesObserver); // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_TIME_TICK); filter.addAction(Intent.ACTION_TIME_CHANGED); filter.addAction(Intent.ACTION_TIMEZONE_CHANGED); getActivity().registerReceiver(mReceiver, filter, null, new Handler()); }
From source file:chat.client.gui.ChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); myNum = tm.getLine1Number();//from w w w . j a va 2s .c o m Bundle extras = getIntent().getExtras(); if (extras != null) { nickname = extras.getString("nickname"); } provider = LocationManager.GPS_PROVIDER; locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(provider); locationManager.requestLocationUpdates(provider, 0, 0, new LocationListener() { @Override public void onLocationChanged(Location location) { // if (location != null) // updateWithNewLocation(location); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } }); try { chatClientInterface = MicroRuntime.getAgent(nickname).getO2AInterface(ChatClientInterface.class); } catch (StaleProxyException e) { showAlertDialog(getString(R.string.msg_interface_exc), true); } catch (ControllerException e) { showAlertDialog(getString(R.string.msg_controller_exc), true); } myReceiver = new MyReceiver(); IntentFilter refreshChatFilter = new IntentFilter(); refreshChatFilter.addAction("jade.demo.chat.REFRESH_CHAT"); registerReceiver(myReceiver, refreshChatFilter); IntentFilter clearChatFilter = new IntentFilter(); clearChatFilter.addAction("jade.demo.chat.CLEAR_CHAT"); registerReceiver(myReceiver, clearChatFilter); setContentView(R.layout.chat); Button button = (Button) findViewById(R.id.button_send); button.setOnClickListener(buttonSendListener); TelephonyManager mgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); listener = new PhoneCallListener(); mgr.listen(listener, PhoneStateListener.LISTEN_CALL_STATE); }
From source file:au.org.ala.fielddata.mobile.ViewSavedRecordsActivity.java
@Override public void onResume() { super.onResume(); reload();/*w ww . j av a 2s.c o m*/ uploadReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { reload(); } }; IntentFilter filter = new IntentFilter(); filter.addAction(UploadService.UPLOAD_FAILED); filter.addAction(UploadService.UPLOADED); filter.addAction(UploadService.STATUS_CHANGE); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(uploadReceiver, filter); }
From source file:com.ieeton.agency.activity.ContactlistFragment.java
private void initView() { IntentFilter filter = new IntentFilter(); filter.addAction(Constants.ACTION_FOLLOW); filter.addAction(Constants.ACTION_UNFOLLOW); mReceiver = new OperationReceiver(); getActivity().registerReceiver(mReceiver, filter); mPullDownView = (PullDownView) mView.findViewById(R.id.pulldown_view); mPullDownView.setUpdateHandle(this); mListView = (SwipeListView) mView.findViewById(R.id.list); mAdapter = new HomeListAdapter(); mListView.setAdapter(mAdapter);/* ww w. ja v a2 s . c o m*/ mListView.setOnScrollListener(this); mListView.setSwipeListViewListener(new BaseSwipeListViewListener() { @Override public void onClickFrontView(int position) { if (mList != null && position < mList.size()) { UserInfo user = mList.get(position); if (user == null) { return; } if (user.getUserType() == UserInfo.ACCOUNT_DOCTOR) { Doctor doctor = user.getDoctor(); if (doctor == null) { return; } Intent intent = new Intent(getActivity(), UserProfileActivity.class); intent.putExtra(UserProfileActivity.EXTRA_USERINFO, new ChatUser(doctor)); startActivity(intent); } else { Patient patient = user.getPatient(); if (patient == null) { return; } Intent intent = new Intent(getActivity(), PatientProfileActivity.class); intent.putExtra(PatientProfileActivity.EXTRA_USERID, patient.getID()); startActivity(intent); } } } }); if (mList == null || mList.isEmpty()) { refreshData(LOAD_REFRESH); } }
From source file:cn.changwentao.ad.BannerAdView.java
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); getContext().registerReceiver(mReceiver, filter, null, mHandler); if (mAutoStart) { // ?//from ww w .j ava2s . c om startFlipping(); } }
From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java
private void registerSmsReceiverIfNeeded() { if (!useSmsReceiver) { return;//from w ww .ja v a2 s . co m } if (smsReceiver != null) { return; } Logger.d("registerSmsReceiver"); smsReceiver = new SmsReceiver(new ISmsReceiver() { @Override public void onCompleteSms(String code) { Logger.d("++ onCompleteSms(%s)", code); if (!TextUtils.isEmpty(code)) { final String url = String.format(Locale.US, "javascript:insertSms('%s')", code); Logger.d("++ command : " + url); webView.loadUrl(url); } } }); IntentFilter filter = new IntentFilter(); filter.addAction(SmsReceiver.ACTION); filter.setPriority(999); // ? SMS ?? SMS priority 3 . getContext().getApplicationContext().registerReceiver(smsReceiver, filter); }
From source file:uk.ac.ucl.excites.sapelli.relay.BackgroundService.java
/** * Register an SMS Data (Binary) Receiver *//* ww w .j a v a 2 s .c o 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."); }