List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter()
From source file:com.grupohqh.carservices.operator.ReadTagActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_tag); URL = getString(R.string.base_url) + getString(R.string.findcarid_url); if (getIntent().getExtras().containsKey("userId")) userId = getIntent().getExtras().getInt("userId"); rgSearchBy = (RadioGroup) findViewById(R.id.rgSearchBy); etTag = (EditText) findViewById(R.id.etTag); etLicensePlate = (EditText) findViewById(R.id.etLicensePlate); etSerialNumber = (EditText) findViewById(R.id.etSerialNumber); btnSearch = (Button) findViewById(R.id.btnSearch); viewTag = findViewById(R.id.viewTag); viewPlate = findViewById(R.id.viewPlate); viewSerial = findViewById(R.id.viewSerial); changeVisibility(rgSearchBy.getCheckedRadioButtonId()); rgSearchBy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override// w w w .j a v a 2 s . c o m public void onCheckedChanged(RadioGroup group, int checkedId) { changeVisibility(checkedId); } }); btnSearch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (validate()) { new HttpAsyncTask().execute(URL); } } }); if (useMiniMe) { manager = (UsbManager) getSystemService(Context.USB_SERVICE); usbCommunication = UsbCommunication.newInstance(); IntentFilter filter = new IntentFilter(); filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); // will intercept by system filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED); filter.addAction(ACTION_USB_PERMISSION); registerReceiver(usbReceiver, filter); etEpc = (EditText) findViewById(R.id.etEPC); btnRead = (Button) findViewById(R.id.btnReadTAG); txtStatus = (TextView) findViewById(R.id.txtStatus); btnRead.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { etEpc.setText(""); if (txtStatus.getText().toString().equals("conectado")) { readTag(); } else { Toast.makeText(getBaseContext(), "dispositivo " + txtStatus.getText(), Toast.LENGTH_LONG) .show(); } } }); } }
From source file:com.aware.ui.Plugins_Manager.java
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.plugins_store_ui); super.onCreate(savedInstanceState); inflater = getLayoutInflater();// ww w . j a v a 2s . co m store_grid = (GridLayout) findViewById(R.id.plugins_store_grid); loading_plugins = (ProgressBar) findViewById(R.id.loading_plugins); IntentFilter filter = new IntentFilter(); filter.addAction(Aware.ACTION_AWARE_PLUGIN_MANAGER_REFRESH); registerReceiver(plugins_listener, filter); }
From source file:com.example.android.geofence.DGGeofencing.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equalsIgnoreCase("initCallbackForRegionMonitoring")) { cbContext = callbackContext;/* w w w.ja v a2 s. co m*/ } else if (action.equalsIgnoreCase("startMonitoringRegion")) { // Create an intent filter for the broadcast receiver mIntentFilter = new IntentFilter(); // Action for broadcast Intents that report successful addition of geofences mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_ADDED); // Action for broadcast Intents that report successful removal of geofences mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED); // Action for broadcast Intents containing various types of geofencing errors mIntentFilter.addAction(GeofenceUtils.ACTION_GEOFENCE_ERROR); // All Location Services sample apps use this category mIntentFilter.addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES); // Instantiate the current List of geofences mCurrentGeofences = new ArrayList<Geofence>(); // Instantiate a Geofence requester mGeofenceRequester = new GeofenceRequester(this.cordova.getActivity()); // Instantiate a Geofence remover mGeofenceRemover = new GeofenceRemover(this.cordova.getActivity()); // Attach to the main UI //setContentView(R.layout.activity_main); /* * Record the request as an ADD. If a connection error occurs, * the app can automatically restart the add request if Google Play services * can fix the error */ mRequestType = GeofenceUtils.REQUEST_TYPE.ADD; /* * Check for Google Play services. Do this after * setting the request type. If connecting to Google Play services * fails, onActivityResult is eventually called, and it needs to * know what type of request was in progress. */ if (!servicesConnected()) { return false; } /* * Create a version of geofence 1 that is "flattened" into individual fields. This * allows it to be stored in SharedPreferences. */ double lat = Double.valueOf(args.getString(1)); double lng = Double.valueOf(args.getString(2)); float radius = Float.valueOf(args.getString(3)); mUIGeofence1 = new SimpleGeofence("1", // Get latitude, longitude, and radius from the UI lat, lng, radius, // Set the expiration time GEOFENCE_EXPIRATION_IN_MILLISECONDS, // Only detect entry transitions Geofence.GEOFENCE_TRANSITION_ENTER); /* * Add Geofence objects to a List. toGeofence() * creates a Location Services Geofence object from a * flat object */ mCurrentGeofences.add(mUIGeofence1.toGeofence()); // Start the request. Fail if there's already a request in progress try { // Try to add geofences mGeofenceRequester.addGeofences(mCurrentGeofences); } catch (UnsupportedOperationException e) { // Notify user that previous request hasn't finished. } } return true; }
From source file:com.example.testplayer.NetworkManager.java
/** * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * * @param cordova The context of the main Activity. * @param webView The CordovaWebView Cordova is running in. *///from w ww . j av a 2 s .c om public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); this.connectionCallbackContext = null; // We need to listen to connectivity events to update navigator.connection IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // (The null check is for the ARM Emulator, please use Intel Emulator for better results) if (NetworkManager.this.webView != null) updateConnectionInfo(sockMan.getActiveNetworkInfo()); } }; webView.getContext().registerReceiver(this.receiver, intentFilter); } }
From source file:etsii_upm.obdii.EnviarService.java
@Override public void onCreate() { super.onCreate(); // Suscribe el BroadcastReceiver que instanciamos previamente a los // eventos relacionados con Internet que queremos controlar mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); iFiltro = new IntentFilter(); iFiltro.addAction(ConnectivityManager.CONNECTIVITY_ACTION); iReceiver = new iBroadcastR(); this.registerReceiver(iReceiver, iFiltro); //Inicializamos el thread de envio mHandler = new threadHandler(); enviarThread = new EnviarThread(mHandler); }
From source file:com.polyvi.xface.extension.XNetworkConnectionExt.java
/** * ? plugin NetworkConnection ./*from w w w .j a v a 2 s . c o m*/ * Android ??BroadcastReceiver Android broadcast * */ public void initConnectionContext() { Context context = getContext(); this.mSockMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); // ????connection IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); if (this.mReceiver == null) { this.mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateConnectionInfo( (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO)); } }; context.registerReceiver(this.mReceiver, intentFilter); } }
From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.SystemMonitor.java
@Override public void onCreate() { super.onCreate(); // Use filter for Monitor Significant Changes in Battery Level only // Generally speaking, the impact of constantly monitoring the // battery/*from ww w. j av a2 s . c o m*/ // level has a greater impact on the battery than your app's normal // behavior, so it's good practice to only monitor significant // changes // in battery levelspecifically when the device enters or exits a // low // battery state. IntentFilter ifilter = new IntentFilter(); ifilter.addAction(Intent.ACTION_BATTERY_CHANGED); // ifilter.addAction(Intent.ACTION_BATTERY_OKAY); this.registerReceiver(batteryLvlReceiver, ifilter); // get Location MyLocation myLocation = new MyLocation(); myLocation.getLocation(this, locationResult); // scheduleNextUpdate(); // Notify user of this service // systemNotice(); this.stopSelf(); }
From source file:android.net.http.cts.ApacheHttpClientTest.java
private void connectToWifi() throws InterruptedException { if (!mWifiManager.isWifiEnabled()) { ConnectivityActionReceiver receiver = new ConnectivityActionReceiver(ConnectivityManager.TYPE_WIFI, State.CONNECTED); IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); mContext.registerReceiver(receiver, filter); assertTrue(mWifiManager.setWifiEnabled(true)); assertTrue("Wifi must be configured to connect to an access point for this test.", receiver.waitForStateChange()); mContext.unregisterReceiver(receiver); }/*from w w w . j a v a 2s . c o m*/ }
From source file:io.teak.sdk.Session.java
private Session(AppConfiguration appConfiguration, DeviceConfiguration deviceConfiguration) { // State: Created // Valid data: // - startDate // - appConfiguration // - deviceConfiguration this.startDate = new Date(); this.appConfiguration = appConfiguration; this.deviceConfiguration = deviceConfiguration; DeviceConfiguration.addEventListener(this.deviceConfigurationListener); IntentFilter filter = new IntentFilter(); filter.addAction(FacebookAccessTokenBroadcast.UPDATED_ACCESS_TOKEN_INTENT_ACTION); Teak.localBroadcastManager.registerReceiver(this.facebookBroadcastReceiver, filter); setState(State.Created);//from w w w . j av a2 s .c o m }
From source file:fr.gotorennes.AbstractMapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayout());/*from w ww. ja va 2 s .c o m*/ mapView = (MapView) findViewById(R.id.mapView); mapController = mapView.getController(); myLocationOverlay = new MyLocationOverlay(this, mapView); // Add ZoomControls zoomControls = (ZoomControls) findViewById(R.id.zoomControl); zoomControls.setOnZoomInClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mapController.zoomIn(); onMapChange(); } }); zoomControls.setOnZoomOutClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { mapController.zoomOut(); onMapChange(); } }); addMyLocationOverlay(); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { finish(); } }; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(AbstractActivity.ACTION_LOGOUT); registerReceiver(receiver, intentFilter); BackgroundTask<Boolean> backgroundInit = new BackgroundTask<Boolean>() { @Override protected Boolean execute() { try { goToRennes = GoToRennes.getInstance(AbstractMapActivity.this, null); } catch (Exception ex) { return false; } return true; } @Override protected void callback(Boolean result) { if (result == null || !result) { showError(getString(R.string.erreurInitialisation), true); } else { init(); goToRennes.track(getTrackingName()); } } }; backgroundInit.start(this); }