List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:info.snowhow.plugin.RecorderService.java
@Override public void onCreate() { Log.d(LOG_TAG, "onCreate called in service"); mgpsll = new MyLocationListener(); mnetll = new MyLocationListener(); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); editor = sharedPref.edit();//from w ww . j av a 2 s . co m locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Log.d(LOG_TAG, "locationManager initialized, starting intent"); try { PackageManager packageManager = this.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), 0); applicationName = packageManager.getApplicationLabel(packageInfo.applicationInfo).toString(); } catch (android.content.pm.PackageManager.NameNotFoundException e) { /* do nothing, fallback is used as name */ } registerReceiver(RecorderServiceBroadcastReceiver, new IntentFilter(ifString)); startGPSS(); }
From source file:com.librelio.activity.MainMagazineActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.issue_list_layout); overridePendingTransition(R.anim.flip_right_in, R.anim.flip_left_out); plistName = getIntent().getStringExtra(PLIST_NAME_EXTRA); if (!plistName.equals(getString(R.string.root_view))) { getActionBar().setDisplayHomeAsUpEnabled(true); }// ww w.ja va2 s . c o m hasTestMagazine = hasTestMagazine(); grid = (GridView) findViewById(R.id.issue_list_grid_view); magazines = new ArrayList<DictItem>(); adapter = new MagazineAdapter(magazines, this, hasTestMagazine); grid.setAdapter(adapter); IntentFilter subsFilter = new IntentFilter(REQUEST_SUBS); registerReceiver(subscriptionYear, subsFilter); registerReceiver(subscriptionMonthly, subsFilter); getLoaderManager().initLoader(PLIST_PARSER_LOADER, null, this); }
From source file:fm.libre.droid.LibreDroid.java
/** Called when the activity is first created. */ @Override/*from w w w . j a va 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); libreServiceConn = new LibreServiceConnection(); bindService(new Intent(this, LibreService.class), libreServiceConn, Context.BIND_AUTO_CREATE); this.registerReceiver(new MediaButtonReceiver(), new IntentFilter(Intent.ACTION_MEDIA_BUTTON)); this.registerReceiver(new UIUpdateReceiver(), new IntentFilter("LibreDroidNewSong")); setContentView(R.layout.main); // Load settings final SharedPreferences settings = getSharedPreferences("LibreDroid", MODE_PRIVATE); username = settings.getString("Username", ""); password = settings.getString("Password", ""); final EditText usernameEntry = (EditText) findViewById(R.id.usernameEntry); final EditText passwordEntry = (EditText) findViewById(R.id.passwordEntry); usernameEntry.setText(username); passwordEntry.setText(password); final Button loginButton = (Button) findViewById(R.id.loginButton); loginButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Editor editor = settings.edit(); editor.putString("Username", usernameEntry.getText().toString()); editor.putString("Password", passwordEntry.getText().toString()); editor.commit(); LibreDroid.this.login(); } }); stations = new ArrayList<String>(); try { BufferedReader stationReader = new BufferedReader( new InputStreamReader(openFileInput("libredroid-custom-stations.conf"))); String station; while ((station = stationReader.readLine()) != null) { stations.add(station); } stationReader.close(); } catch (IOException ex) { Log.d("libredroid", ex.getMessage()); } // Add default stations if empty if (stations.isEmpty()) { String radioButtons[] = { "Folk", "Rock", "Metal", "Classical", "Pop", "Punk", "Jazz", "Blues", "Rap", "Ambient", "Add A Custom Station..." }; stations.addAll(Arrays.asList(radioButtons)); } setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, stations)); Button tagStation = (Button) findViewById(R.id.tagStationButton); tagStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.nextPage(); } }); Button loveStation = (Button) findViewById(R.id.loveStationButton); loveStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.tuneStation("user", username + "/loved"); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); } }); Button communityLoveStation = (Button) findViewById(R.id.communityStationButton); communityLoveStation.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.tuneStation("community", "loved"); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); LibreDroid.this.nextPage(); } }); final ImageButton nextButton = (ImageButton) findViewById(R.id.nextButton); nextButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.next(); } }); final ImageButton prevButton = (ImageButton) findViewById(R.id.prevButton); prevButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.prev(); } }); final ImageButton playPauseButton = (ImageButton) findViewById(R.id.playPauseButton); playPauseButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.togglePause(); } }); final ImageButton saveButton = (ImageButton) findViewById(R.id.saveButton); saveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.save(); } }); final ImageButton loveButton = (ImageButton) findViewById(R.id.loveButton); loveButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.love(); } }); final ImageButton banButton = (ImageButton) findViewById(R.id.banButton); banButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.libreServiceConn.service.ban(); } }); final Button addStationButton = (Button) findViewById(R.id.addStationButton); addStationButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { LibreDroid.this.addStation(); } }); }
From source file:com.mobicage.rogerthat.plugins.scan.ProcessScanActivity.java
@Override protected void onServiceBound() { T.UI();// w w w.j a v a 2 s . com mFriendsPlugin = mService.getPlugin(FriendsPlugin.class); mBroadcastReceiver = getBroadcastReceiver(); final IntentFilter filter = new IntentFilter(FriendsPlugin.FRIEND_INFO_RECEIVED_INTENT); filter.addAction(FriendsPlugin.SERVICE_ACTION_INFO_RECEIVED_INTENT); filter.addAction(URL_REDIRECTION_DONE); registerReceiver(mBroadcastReceiver, filter); Intent intent = getIntent(); final String url = intent.getStringExtra(URL); final String emailHash = intent.getStringExtra(EMAILHASH); if (url == null && emailHash == null) { L.bug("url == null && emailHash == null"); finish(); } else { startSpinner(intent.getBooleanExtra(SCAN_RESULT, false)); if (url != null) processUrl(url); else processEmailHash(emailHash); } }
From source file:cn.edu.zju.bme319.cordova.ExtraInfo.java
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Activity activity = this.cordova.getActivity(); context = (Context) this.context; //from w ww .j a v a 2 s. co m // Register for broadcasts when a device is discovered IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); context.registerReceiver(mReceiver, filter); // Register for broadcasts when discovery starts filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED); context.registerReceiver(mReceiver, filter); // Register for broadcasts when discovery has finished filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); context.registerReceiver(mReceiver, filter); // Register for broadcasts when connectivity state changes filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); context.registerReceiver(mReceiver, filter); Looper.prepare(); found_devices = new ArrayList<BluetoothDevice>(); if (btadapter == null) { btadapter = BluetoothAdapter.getDefaultAdapter(); } if (action.equals("getExtra")) { callbackContext.success("123"); return true; } else if (ACTION_DISCOVER_DEVICES.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_DISCOVER_DEVICES); found_devices.clear(); discovering=true; if (btadapter.isDiscovering()) { btadapter.cancelDiscovery(); } Log.i("BluetoothPlugin","Discovering devices..."); btadapter.startDiscovery(); while (discovering){} String devicesFound=null; int count=0; devicesFound="["; for (BluetoothDevice device : found_devices) { Log.i("BluetoothPlugin",device.getName() + " "+device.getAddress()+" "+device.getBondState()); if ((device.getName()!=null) && (device.getBluetoothClass()!=null)){ devicesFound = devicesFound + " { \"name\" : \"" + device.getName() + "\" ," + "\"address\" : \"" + device.getAddress() + "\" ," + "\"class\" : \"" + device.getBluetoothClass().getDeviceClass() + "\" }"; if (count<found_devices.size()-1) devicesFound = devicesFound + ","; }else Log.i("BluetoothPlugin",device.getName() + " Problems retrieving attributes. Device not added "); count++; } devicesFound= devicesFound + "] "; Log.d("BluetoothPlugin - "+ACTION_DISCOVER_DEVICES, "Returning: "+ devicesFound); callbackContext.success(devicesFound); //result = new PluginResult(Status.OK, devicesFound); } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_DISCOVER_DEVICES, "Got Exception "+ Ex.getMessage()); callbackContext.error("discoveryError"); //result = new PluginResult(Status.ERROR); } // try { // // Log.d("BluetoothPlugin", "We're in "+ACTION_DISCOVER_DEVICES); // // // Create a BroadcastReceiver for ACTION_FOUND //// final BroadcastReceiver mReceiver = new BroadcastReceiver() { //// public void onReceive(Context context, Intent intent) { //// String action = intent.getAction(); //// // When discovery finds a device //// if (BluetoothDevice.ACTION_FOUND.equals(action)) { //// // Get the BluetoothDevice object from the Intent //// BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); //// // Add the name and address to an array adapter to show in a ListView //// mArrayAdapter.add(device.getName() + "\n" + device.getAddress()); //// } //// } //// }; //// // Register the BroadcastReceiver //// IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); //// registerReceiver(mReceiver, filter); // Don't forget to unregister during onDestroy //// //// // ?? //// if (btadapter.isDiscovering()) { //// btadapter.cancelDiscovery(); //// Log.d("BluetoothPlugin", "We're in "+"12"); //// } //// //? //// Log.d("BluetoothPlugin", "We're in "+"1234"); //// btadapter.startDiscovery(); //// Log.d("BluetoothPlugin", "We're in "+"123456"); //// //// found_devices.clear(); //// //discovering=true; //// //// //if (btadapter.isDiscovering()) { //// // btadapter.cancelDiscovery(); //// //} //// //// SendCommand(0); //// //// Log.i("BluetoothPlugin","Discovering devices..."); //// //btadapter.startDiscovery(); //// //// while (discovering){} //// //// String devicesFound=null; //// int count=0; //// devicesFound="["; //// for (BluetoothDevice device : found_devices) { //// Log.i("BluetoothPlugin",device.getName() + " "+device.getAddress()+" "+device.getBondState()); //// if ((device.getName()!=null) && (device.getBluetoothClass()!=null)){ //// devicesFound = devicesFound + " { \"name\" : \"" + device.getName() + "\" ," + //// "\"address\" : \"" + device.getAddress() + "\" ," + //// "\"class\" : \"" + device.getBluetoothClass().getDeviceClass() + "\" }"; //// if (count<found_devices.size()-1) devicesFound = devicesFound + ","; //// }else Log.i("BluetoothPlugin",device.getName() + " Problems retrieving attributes. Device not added "); //// count++; //// } //// //// devicesFound= devicesFound + "] "; //// //// Log.d("BluetoothPlugin - "+ACTION_DISCOVER_DEVICES, "Returning: "+ devicesFound); //// callbackContext.success(devicesFound); // //result = new PluginResult(Status.OK, devicesFound); // return true; // } catch (Exception Ex) { // Log.d("BluetoothPlugin - "+ACTION_DISCOVER_DEVICES, "Got Exception "+ Ex.getMessage()); // //result = new PluginResult(Status.ERROR); // callbackContext.error("discoverError"); // return false; // } } else if (ACTION_IS_BT_ENABLED.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_IS_BT_ENABLED); boolean isEnabled = btadapter.isEnabled(); Log.d("BluetoothPlugin - "+ACTION_IS_BT_ENABLED, "Returning "+ "is Bluetooth Enabled? "+isEnabled); callbackContext.success(""+isEnabled); //result = new PluginResult(Status.OK, isEnabled); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_IS_BT_ENABLED, "Got Exception "+ Ex.getMessage()); callbackContext.error("isBTEnabledError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_ENABLE_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_ENABLE_BT); boolean enabled = false; Log.d("BluetoothPlugin", "Enabling Bluetooth..."); if (btadapter.isEnabled()) { enabled = true; } else { enabled = btadapter.enable(); } Log.d("BluetoothPlugin - "+ACTION_ENABLE_BT, "Returning "+ "Result: "+enabled); callbackContext.success("" + enabled); //result = new PluginResult(Status.OK, enabled); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_ENABLE_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("EnableBTError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_DISABLE_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_DISABLE_BT); boolean disabled = false; Log.d("BluetoothPlugin", "Disabling Bluetooth..."); if (btadapter.isEnabled()) { disabled = btadapter.disable(); } else { disabled = true; } Log.d("BluetoothPlugin - "+ACTION_DISABLE_BT, "Returning "+ "Result: "+disabled); callbackContext.success("" + disabled); //result = new PluginResult(Status.OK, disabled); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_DISABLE_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("DisableBTError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_PAIR_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_PAIR_BT); String addressDevice = args.getString(0); if (btadapter.isDiscovering()) { btadapter.cancelDiscovery(); } BluetoothDevice device = btadapter.getRemoteDevice(addressDevice); boolean paired = false; Log.d("BluetoothPlugin","Pairing with Bluetooth device with name " + device.getName()+" and address "+device.getAddress()); try { Method m = device.getClass().getMethod("createBond"); paired = (Boolean) m.invoke(device); } catch (Exception e) { e.printStackTrace(); } Log.d("BluetoothPlugin - "+ACTION_PAIR_BT, "Returning "+ "Result: "+paired); callbackContext.success("" + paired); //result = new PluginResult(Status.OK, paired); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_PAIR_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("pairBTError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_UNPAIR_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_UNPAIR_BT); String addressDevice = args.getString(0); if (btadapter.isDiscovering()) { btadapter.cancelDiscovery(); } BluetoothDevice device = btadapter.getRemoteDevice(addressDevice); boolean unpaired = false; Log.d("BluetoothPlugin","Unpairing Bluetooth device with " + device.getName()+" and address "+device.getAddress()); try { Method m = device.getClass().getMethod("removeBond"); unpaired = (Boolean) m.invoke(device); } catch (Exception e) { e.printStackTrace(); } Log.d("BluetoothPlugin - "+ACTION_UNPAIR_BT, "Returning "+ "Result: "+unpaired); callbackContext.success("" + unpaired); //result = new PluginResult(Status.OK, unpaired); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_UNPAIR_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("unpairBTError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_LIST_BOUND_DEVICES.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_LIST_BOUND_DEVICES); Log.d("BluetoothPlugin","Getting paired devices..."); //? Set<BluetoothDevice> pairedDevices = btadapter.getBondedDevices(); int count =0; String resultBoundDevices="[ "; if (pairedDevices.size() > 0) { for (BluetoothDevice device : pairedDevices) { Log.i("BluetoothPlugin",device.getName() + " "+device.getAddress()+" "+device.getBondState()); if ((device.getName()!=null) && (device.getBluetoothClass()!=null)){ resultBoundDevices = resultBoundDevices + " { \"name\" : \"" + device.getName() + "\" ," + "\"address\" : \"" + device.getAddress() + "\" ," + "\"class\" : \"" + device.getBluetoothClass().getDeviceClass() + "\" }"; if (count<pairedDevices.size()-1) resultBoundDevices = resultBoundDevices + ","; } else Log.i("BluetoothPlugin",device.getName() + " Problems retrieving attributes. Device not added "); count++; } } resultBoundDevices= resultBoundDevices + "] "; Log.d("BluetoothPlugin - "+ACTION_LIST_BOUND_DEVICES, "Returning "+ resultBoundDevices); callbackContext.success("" + resultBoundDevices); //result = new PluginResult(Status.OK, resultBoundDevices); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_LIST_BOUND_DEVICES, "Got Exception "+ Ex.getMessage()); callbackContext.error("resultBoundDevicesError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_STOP_DISCOVERING_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_STOP_DISCOVERING_BT); boolean stopped = true; Log.d("BluetoothPlugin", "Stop Discovering Bluetooth Devices..."); if (btadapter.isDiscovering()) { Log.i("BluetoothPlugin","Stop discovery..."); stopped = btadapter.cancelDiscovery(); discovering=false; } Log.d("BluetoothPlugin - "+ACTION_STOP_DISCOVERING_BT, "Returning "+ "Result: "+stopped); callbackContext.success("" + stopped); //result = new PluginResult(Status.OK, stopped); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_STOP_DISCOVERING_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("stoppedError"); //result = new PluginResult(Status.ERROR); return false; } } else if (ACTION_IS_BOUND_BT.equals(action)) { try { Log.d("BluetoothPlugin", "We're in "+ACTION_IS_BOUND_BT); String addressDevice = args.getString(0); BluetoothDevice device = btadapter.getRemoteDevice(addressDevice); Log.i("BluetoothPlugin","BT Device in state "+device.getBondState()); boolean state = false; if (device!=null && device.getBondState()==12) state = true; else state = false; Log.d("BluetoothPlugin","Is Bound with " + device.getName()+" - address "+device.getAddress()); Log.d("BluetoothPlugin - "+ACTION_IS_BOUND_BT, "Returning "+ "Result: "+state); callbackContext.success("" + state); //result = new PluginResult(Status.OK, state); return true; } catch (Exception Ex) { Log.d("BluetoothPlugin - "+ACTION_IS_BOUND_BT, "Got Exception "+ Ex.getMessage()); callbackContext.error("boundBTError"); //result = new PluginResult(Status.ERROR); return false; } } else if(ACTION_BT_CONNECT.equals(action)){ try { Log.d("BluetoothPlugin", "We're in "+ACTION_BT_CONNECT); deviceAddress = "8C:DE:52:99:26:23"; Log.d("BluetoothPlugin", "We're in "+deviceAddress); BluetoothDevice device = btadapter.getRemoteDevice(deviceAddress); //m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class }); //bluetoothSocket = (BluetoothSocket) m.invoke(device, Integer.valueOf(1)); //SendCommand(0); // ??socket try { bluetoothSocket = device.createRfcommSocketToServiceRecord(UUID .fromString(MY_UUID)); } catch (IOException e) { //Toast.makeText(this, "?", Toast.LENGTH_SHORT).show(); } bluetoothSocket.connect(); sendCommandFlag = 0; SendCommand(sendCommandFlag); if(bluetoothSocket.isConnected()) { this.isConnection = true; String str = ""; // try { inputStream = bluetoothSocket.getInputStream(); // ??? str = ""+1; } catch (IOException e) { //Toast.makeText(this, "??", Toast.LENGTH_SHORT).show(); //return; str=""+2; } if (bThread == false) { ReadThread.start(); bThread = true; str = ""+3; } else { bRun = true; str = ""+4; } //result = new PluginResult(Status.OK, str); //result.setKeepCallback(true); // callbackContext.sendPluginResult(result); callbackContext.success("" + str); } else { //result = new PluginResult(Status.OK, "failure"); callbackContext.error("Could not connect to "); } return true; } catch (Exception Ex) { // TODO: handle exception Log.d("BluetoothPlugin - "+ACTION_BT_CONNECT, "Got Exception "+ Ex.getMessage()); //result = new PluginResult(Status.ERROR); callbackContext.error("Could not connect to "); return false; } }else if(ACTION_BT_GETDATA.equals(action)){ try { Log.d("BluetoothPlugin", "We're in "+ACTION_BT_GETDATA); sendCommandFlag = 1; SendCommand(sendCommandFlag); // if (bluetoothSocket != null) { // if(bluetoothSocket.isConnected()){ // SendCommand(1); // } // } // //result = new PluginResult(Status.OK, spoValue); Log.v("Get1 ", returnBTData); while(returnBTData == "") { Log.v("Get2 ", returnBTData); } Log.v("Get3 ", returnBTData); callbackContext.success("" + returnBTData); //ReadThread.cancel(); bluetoothSocket.close(); bluetoothSocket = null; return true; } catch (Exception Ex) { // TODO: handle exception Log.d("BluetoothPlugin - "+ACTION_BT_GETDATA, "Got Exception "+ Ex.getMessage()); callbackContext.error("" + "getDataError"); //result = new PluginResult(Status.ERROR); return false; } } else { // result = new PluginResult(Status.INVALID_ACTION); // Log.d("BluetoothPlugin", "Invalid action : "+action+" passed"); // return result; callbackContext.error("" + "actionError"); } return false; }
From source file:com.geniatech.client_phone.wifi.WifiStatusTest.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); mWifiStateFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.RSSI_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); registerReceiver(mWifiStateReceiver, mWifiStateFilter); setContentView(R.layout.wifi_status_test); updateButton = (Button) findViewById(R.id.update); updateButton.setOnClickListener(updateButtonHandler); mWifiState = (TextView) findViewById(R.id.wifi_state); mNetworkState = (TextView) findViewById(R.id.network_state); mSupplicantState = (TextView) findViewById(R.id.supplicant_state); mRSSI = (TextView) findViewById(R.id.rssi); mBSSID = (TextView) findViewById(R.id.bssid); mSSID = (TextView) findViewById(R.id.ssid); mHiddenSSID = (TextView) findViewById(R.id.hidden_ssid); mIPAddr = (TextView) findViewById(R.id.ipaddr); mMACAddr = (TextView) findViewById(R.id.macaddr); mNetworkId = (TextView) findViewById(R.id.networkid); mLinkSpeed = (TextView) findViewById(R.id.link_speed); mScanList = (TextView) findViewById(R.id.scan_list); }
From source file:com.hzl.administrator.wifi.WifiStatusTest.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); mWifiStateFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); mWifiStateFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.RSSI_CHANGED_ACTION); mWifiStateFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); registerReceiver(mWifiStateReceiver, mWifiStateFilter); setContentView(R.layout.wifi_status_test); updateButton = (Button) findViewById(R.id.update); updateButton.setOnClickListener(updateButtonHandler); mWifiState = (TextView) findViewById(R.id.wifi_state); mNetworkState = (TextView) findViewById(R.id.network_state); mSupplicantState = (TextView) findViewById(R.id.supplicant_state); mRSSI = (TextView) findViewById(R.id.rssi); mBSSID = (TextView) findViewById(R.id.bssid); mSSID = (TextView) findViewById(R.id.ssid); mHiddenSSID = (TextView) findViewById(R.id.hidden_ssid); mIPAddr = (TextView) findViewById(R.id.ipaddr); mMACAddr = (TextView) findViewById(R.id.macaddr); mNetworkId = (TextView) findViewById(R.id.networkid); mLinkSpeed = (TextView) findViewById(R.id.link_speed); mScanList = (TextView) findViewById(R.id.scan_list); mPingIpAddr = (TextView) findViewById(R.id.pingIpAddr); mPingHostname = (TextView) findViewById(R.id.pingHostname); mHttpClientTest = (TextView) findViewById(R.id.httpClientTest); pingTestButton = (Button) findViewById(R.id.ping_test); pingTestButton.setOnClickListener(mPingButtonHandler); }
From source file:com.easemob.chatuidemo.DemoHXSDKHelper.java
@Override protected void initListener() { super.initListener(); IntentFilter callFilter = new IntentFilter(EMChatManager.getInstance().getIncomingCallBroadcastAction()); if (callReceiver == null) { callReceiver = new CallReceiver(); }/*from w w w. j av a2s. c o m*/ //? appContext.registerReceiver(callReceiver, callFilter); //?? initEventListener(); }
From source file:com.moodstocks.phonegap.plugin.MoodstocksScanActivity.java
@Override protected void onResume() { super.onResume(); // start scanning! session.resume();/*w w w . j ava 2 s . c o m*/ // Setup the an action receiver for receiving broadcast intent if (MoodstocksActionReceiver == null) MoodstocksActionReceiver = new ActionReceiver(); // Filter on the key word pluginAction to make sure we only take plugin actions // a.k.a MoodstocksPlugin - resume(), pause(), dismiss() IntentFilter intentFilter = new IntentFilter(PLUGINACTION); registerReceiver(MoodstocksActionReceiver, intentFilter); // Update the flag in MoodstocksWebView MoodstocksPlugin.getOverlay().onStatusUpdate(true); }
From source file:com.facebook.AccessTokenManagerTest.java
@Test public void testChangingAccessTokenSendsBroadcast() { AccessTokenManager accessTokenManager = createAccessTokenManager(); AccessToken accessToken = createAccessToken(); accessTokenManager.setCurrentAccessToken(accessToken); final Intent intents[] = new Intent[1]; final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override/*ww w .j a va 2s.c om*/ public void onReceive(Context context, Intent intent) { intents[0] = intent; } }; localBroadcastManager.registerReceiver(broadcastReceiver, new IntentFilter(AccessTokenManager.ACTION_CURRENT_ACCESS_TOKEN_CHANGED)); AccessToken anotherAccessToken = createAccessToken("another string", "1000"); accessTokenManager.setCurrentAccessToken(anotherAccessToken); localBroadcastManager.unregisterReceiver(broadcastReceiver); Intent intent = intents[0]; assertNotNull(intent); AccessToken oldAccessToken = (AccessToken) intent .getParcelableExtra(AccessTokenManager.EXTRA_OLD_ACCESS_TOKEN); AccessToken newAccessToken = (AccessToken) intent .getParcelableExtra(AccessTokenManager.EXTRA_NEW_ACCESS_TOKEN); assertEquals(accessToken.getToken(), oldAccessToken.getToken()); assertEquals(anotherAccessToken.getToken(), newAccessToken.getToken()); }