List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:bolts.AppLinkTest.java
public void testGeneralMeasurementEventsBroadcast() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); i.putExtra("foo", "bar"); ArrayList<String> arr = new ArrayList<>(); arr.add("foo2"); arr.add("bar2"); i.putExtra("foobar", arr); Map<String, String> other = new HashMap<>(); other.put("yetAnotherFoo", "yetAnotherBar"); final CountDownLatch lock = new CountDownLatch(1); final String[] receivedStrings = new String[5]; LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext()); manager.registerReceiver(new BroadcastReceiver() { @Override/* w ww . j av a 2 s .c o m*/ public void onReceive(Context context, Intent intent) { String eventName = intent.getStringExtra("event_name"); Bundle eventArgs = intent.getBundleExtra("event_args"); receivedStrings[0] = eventName; receivedStrings[1] = eventArgs.getString("foo"); receivedStrings[2] = eventArgs.getString("foobar"); receivedStrings[3] = eventArgs.getString("yetAnotherFoo"); receivedStrings[4] = eventArgs.getString("intentData"); lock.countDown(); } }, new IntentFilter("com.parse.bolts.measurement_event")); MeasurementEvent.sendBroadcastEvent(getInstrumentation().getTargetContext(), "myEventName", i, other); lock.await(2000, TimeUnit.MILLISECONDS); assertEquals("myEventName", receivedStrings[0]); assertEquals("bar", receivedStrings[1]); assertEquals((new JSONArray(arr)).toString(), receivedStrings[2]); assertEquals("yetAnotherBar", receivedStrings[3]); assertEquals("http://www.example.com", receivedStrings[4]); }
From source file:com.keithandthegirl.ui.activity.GuestsDashboardFragment.java
@Override public void onResume() { Log.v(TAG, "onResume : enter"); super.onResume(); mDownloadServiceHelper = DownloadServiceHelper.getInstance(getActivity()); IntentFilter downloadFilter = new IntentFilter(DownloadServiceHelper.DOWNLOAD_RESULT); downloadFilter.setPriority(IntentFilter.SYSTEM_LOW_PRIORITY); downloadReceiver = new DownloadReceiver(); getActivity().registerReceiver(downloadReceiver, downloadFilter); if (null != mainApplication.getGuest()) { Log.v(TAG, "onResume : already downloaded guest list"); if (null != mainApplication.getGuest().getGuests() && !mainApplication.getGuest().getGuests().isEmpty()) { Log.v(TAG, "onResume : guestList has entries"); guestList = mainApplication.getGuest().getGuests(); }/*w w w. j a v a 2 s .c o m*/ } if (guestList.isEmpty()) { Log.v(TAG, "onResume : guestList is empty"); File root; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { root = getActivity().getExternalCacheDir(); } else { root = Environment.getExternalStorageDirectory(); } File dataDir = new File(root, DATA_DIR); dataDir.mkdirs(); File f = new File(dataDir, "Guests.xml"); if (f.exists()) { Serializer serializer = new Persister(); try { Guests guests = serializer.read(Guests.class, f); setDownloadedGuests(guests); } catch (Exception e) { Log.w(TAG, "onResume : error reading guests file"); } } else { mainApplication.setGuestSort(MainApplication.Sort.MOST_RECENT); new DownloadGuestTask().execute(MainApplication.Sort.MOST_RECENT); } } else { setupAdapter(); } Log.v(TAG, "onResume : exit"); }
From source file:com.github.notizklotz.derbunddownloader.download.IssueDownloadService.java
@ServiceAction public void downloadIssue(int day, int month, int year) { Log.i(LOG_TAG, "Handling download intent"); try {// w ww. j ava 2 s . com boolean connected; final boolean wifiOnly = Settings.isWifiOnly(getApplicationContext()); if (wifiOnly) { connected = waitForWifiConnection(); if (!connected) { notifyUser(getText(R.string.download_wifi_connection_failed), getText(R.string.download_wifi_connection_failed_text), R.drawable.ic_stat_newspaper); } } else { NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); connected = activeNetworkInfo != null && activeNetworkInfo.isConnected(); if (!connected) { notifyUser(getText(R.string.download_connection_failed), getText(R.string.download_connection_failed_text), R.drawable.ic_stat_newspaper); } } if (connected) { if (!checkUserAccount()) { notifyUser(getText(R.string.download_login_failed), getText(R.string.download_login_failed_text), R.drawable.ic_stat_newspaper); } else { final LocalDate issueDate = new LocalDate(day, month, year); fetchThumbnail(issueDate); final CountDownLatch downloadDoneSignal = new CountDownLatch(1); receiver = new DownloadCompletedBroadcastReceiver(downloadDoneSignal); registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); try { String title = startDownload(issueDate, wifiOnly); downloadDoneSignal.await(); notifyUser(title, getString(R.string.download_completed), R.drawable.ic_stat_newspaper); } catch (InterruptedException e) { Log.wtf(LOG_TAG, "Interrupted while waiting for the downloadDoneSignal"); } } } } catch (Exception e) { notifyUser(getText(R.string.download_service_error), getText(R.string.download_service_error_text) + " " + e.getMessage(), R.drawable.ic_stat_newspaper); } finally { cleanup(); } }
From source file:csic.ceab.movelab.beepath.FixGet.java
public void onStart(Intent intent, int startId) { if (fixInProgress == false) { fixInProgress = true;// w w w .ja v a 2s.c o m stopFilter = new IntentFilter(Util.createInternalMessage(Util.MESSAGE_STOP_FIXGET, context)); stopReceiver = new StopReceiver(); registerReceiver(stopReceiver, stopFilter); announceFixStarted(); if (PropertyHolder.useSensorACCELEROMETER()) startService(new Intent(FixGet.this, SensorGetAccelerometer.class)); if (PropertyHolder.useSensorMAGNETIC_FIELD()) startService(new Intent(FixGet.this, SensorGetMagneticField.class)); if (PropertyHolder.useSensorORIENTATION()) startService(new Intent(FixGet.this, SensorGetOrientation.class)); if (PropertyHolder.useSensorGRAVITY()) startService(new Intent(FixGet.this, SensorGetGravity.class)); if (PropertyHolder.useSensorLINEAR_ACCELERATION()) startService(new Intent(FixGet.this, SensorGetLinear_Acceleration.class)); if (PropertyHolder.useSensorGYROSCOPE()) startService(new Intent(FixGet.this, SensorGetGyroscope.class)); // stopListening = null; bestLocation = null; if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { if (Util.flushGPSFlag == true) { clearGPS(); injectNewXTRA(); Util.flushGPSFlag = false; } locationListener1 = new mLocationListener(); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener1); // mGpsStatusListener= new GpsStatusListener(); // locationManager.addGpsStatusListener(mGpsStatusListener); } if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { locationListener2 = new mLocationListener(); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener2); } } }
From source file:ie.programmer.catcher.AppLinkTest.java
public void testGeneralMeasurementEventsBroadcast() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); i.putExtra("foo", "bar"); ArrayList<String> arr = new ArrayList<>(); arr.add("foo2"); arr.add("bar2"); i.putExtra("foobar", arr); Map<String, String> other = new HashMap<>(); other.put("yetAnotherFoo", "yetAnotherBar"); final CountDownLatch lock = new CountDownLatch(1); final String[] receivedStrings = new String[5]; LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getInstrumentation().getTargetContext()); manager.registerReceiver(new BroadcastReceiver() { @Override/*from ww w .j av a2s .c om*/ public void onReceive(Context context, Intent intent) { String eventName = intent.getStringExtra("event_name"); Bundle eventArgs = intent.getBundleExtra("event_args"); receivedStrings[0] = eventName; receivedStrings[1] = eventArgs.getString("foo"); receivedStrings[2] = eventArgs.getString("foobar"); receivedStrings[3] = eventArgs.getString("yetAnotherFoo"); receivedStrings[4] = eventArgs.getString("intentData"); lock.countDown(); } }, new IntentFilter("com.parse.bolts.measurement_event")); // MeasurementEvent.sendBroadcastEvent(getInstrumentation().getTargetContext(), "myEventName", i, other); lock.await(2000, TimeUnit.MILLISECONDS); assertEquals("myEventName", receivedStrings[0]); assertEquals("bar", receivedStrings[1]); assertEquals((new JSONArray(arr)).toString(), receivedStrings[2]); assertEquals("yetAnotherBar", receivedStrings[3]); assertEquals("http://www.example.com", receivedStrings[4]); }
From source file:samples.piggate.com.piggateInfoDemo.Activity_Logged.java
@Override protected void onResume() { super.onResume(); updateUIlist();/*from ww w . j a va2s . c o m*/ registerReceiver(bReceiver, new IntentFilter("serviceIntent")); }
From source file:ch.ethz.twimight.net.opportunistic.ScanningService.java
private void registerDevicesReceiver() { unregisterDevReceiver();//from w ww . ja v a2 s. c om receiver = new DevicesReceiver(getApplicationContext()); receiver.setListener(this); IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); registerReceiver(receiver, filter); filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); registerReceiver(receiver, filter); }
From source file:com.inloc.dr.StepService.java
@Override public void onCreate() { Log.i(TAG, "[SERVICE] onCreate"); super.onCreate(); dtr = new DataRecorder(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); showNotification();/* w ww . j a va 2s . c om*/ // Load settings mSettings = PreferenceManager.getDefaultSharedPreferences(this); mPedometerSettings = new PedometerSettings(mSettings); mState = getSharedPreferences("state", 0); mUtils = Utils.getInstance(); mUtils.setService(this); acquireWakeLock(); // Start detecting mStepDetector = new StepDetector(); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mTurnDetector = new TurnDetector(); mTurnNotifier = new TurnNotifier(); mTurnNotifier.addListener(mAngleListener); mTurnDetector.addTurnListener(mTurnNotifier); registerDetector(); // Register our receiver for the ACTION_SCREEN_OFF action. This will make our receiver // code be called whenever the phone enters standby mode. IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); registerReceiver(mReceiver, filter); mStepDisplayer = new StepDisplayer(mPedometerSettings, mUtils); mStepDisplayer.setSteps(mSteps = mState.getInt("steps", 0)); mStepDisplayer.addListener(mStepListener); mStepDetector.addStepListener(mStepDisplayer); lSteps = mSteps; mConnManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); File mExternalRoot = android.os.Environment.getExternalStorageDirectory(); mOutputDir = new File(mExternalRoot.getAbsolutePath() + "/datalogs/"); // attempt to make output directory if (!mOutputDir.exists()) { mOutputDir.mkdirs(); } // Used when debugging: // mStepBuzzer = new StepBuzzer(this); // mStepDetector.addStepListener(mStepBuzzer); // Start voice reloadSettings(); // Tell the user we started. Toast.makeText(this, getText(R.string.started), Toast.LENGTH_SHORT).show(); }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
/** * The {@link ViewPager} that will display the three primary sections of the app, one at a * time.//w w w .j a v a2 s .co m */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tabs); init(); mAccount = CreateSyncAccount(this); //registering the broadcast registerReceiver(broadcastReceiver, new IntentFilter("uploadsuccessful")); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.hide(); //atteching fragment to framelayout PickSchoolsFragment myf = new PickSchoolsFragment(); transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.frame, myf); transaction.commit(); llPickSchools.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkcurrentfragment()) { showconfirmationdialog(1); } else { showpickupschool(); } } }); llDrills.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkcurrentfragment()) { showconfirmationdialog(2); } else { showdrill(); } } }); llServiceCalls.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkcurrentfragment()) { showconfirmationdialog(3); } else { showservice(); } } }); llNewInstalls.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkcurrentfragment()) { showconfirmationdialog(4); } else { showinstall(); } } }); llPendingUploads.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (checkcurrentfragment()) { showconfirmationdialog(5); } else { showpending(); } } }); }