List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.moonpi.tapunlock.MainActivity.java
@Override public void onClick(View v) { // If OK(setPin) clicked, ask user if sure; if yes, store PIN; else, go back if (v.getId() == R.id.setPin) { // If PIN length between 4 and 6, store PIN and toast successful if (pinEdit.length() >= 4 && pinEdit.length() <= 6) { new AlertDialog.Builder(this).setMessage(R.string.set_pin_confirmation) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { settings.put("pin", String.valueOf(pinEdit.getText())); } catch (JSONException e) { e.printStackTrace(); }/* ww w.j ava2s .c o m*/ writeToJSON(); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_pin_set, Toast.LENGTH_SHORT); toast.show(); imm.hideSoftInputFromWindow(pinEdit.getWindowToken(), 0); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { imm.hideSoftInputFromWindow(pinEdit.getWindowToken(), 0); // Do nothing, close dialog } }).show(); } // Toast user that PIN needs to be at least 4 digits long else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_pin_needs4digits, Toast.LENGTH_LONG); toast.show(); } } // If 'Refresh wallpaper' pressed, check if Android 4.2 or above, if yes // Store new blur var, if blur bigger than 0 re-blur wallpaper else if (v.getId() == R.id.refreshWallpaper) { if (Build.VERSION.SDK_INT > 16) { try { settings.put("blur", blur); } catch (JSONException e) { e.printStackTrace(); } writeToJSON(); // If blur is 0, don't change anything, just toast if (blur == 0) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_refreshed, Toast.LENGTH_SHORT); toast.show(); } // If blur is bigger than 0, get default wallpaper - to bitmap - fastblur bitmap - store else { // Check if TapUnlock folder exists, if not, create directory File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock"); boolean folderSuccess = true; if (!folder.exists()) { folderSuccess = folder.mkdir(); } if (folderSuccess) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Display indeterminate progress bar while blurring progressBar.setVisibility(View.VISIBLE); new Thread(new Runnable() { @Override public void run() { Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable); Bitmap blurredWallpaper = null; if (bitmapToBlur != null) blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur, blur); boolean stored = false; if (blurredWallpaper != null) { stored = ImageUtils.storeImage(blurredWallpaper); final boolean finalStored = stored; runOnUiThread(new Runnable() { @Override public void run() { progressBar.setVisibility(View.INVISIBLE); if (finalStored) { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_refreshed, Toast.LENGTH_SHORT); toast.show(); } } }); } if (bitmapToBlur == null || blurredWallpaper == null || !stored) { runOnUiThread(new Runnable() { @Override public void run() { progressBar.setVisibility(View.INVISIBLE); Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_not_refreshed, Toast.LENGTH_SHORT); toast.show(); } }); } } }).start(); } else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_wallpaper_not_refreshed, Toast.LENGTH_SHORT); toast.show(); } } } } // If Android version less than 4.2, display toast cannot blur else { Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_cannot_blur, Toast.LENGTH_SHORT); toast.show(); } } // If '+' pressed else if (v.getId() == R.id.newTag) { if (nfcAdapter != null) { // If NFC is on, show scan dialog and enableForegroundDispatch if (nfcAdapter.isEnabled()) { nfcAdapter.enableForegroundDispatch(this, pIntent, new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED) }, new String[][] { new String[] { "android.nfc.tech.MifareClassic" }, new String[] { "android.nfc.tech.MifareUltralight" }, new String[] { "android.nfc.tech.NfcA" }, new String[] { "android.nfc.tech.NfcB" }, new String[] { "android.nfc.tech.NfcF" }, new String[] { "android.nfc.tech.NfcV" }, new String[] { "android.nfc.tech.Ndef" }, new String[] { "android.nfc.tech.IsoDep" }, new String[] { "android.nfc.tech.NdefFormatable" } }); MainActivity.this.showDialog(DIALOG_READ); } // NFC is off, prompt user to enable it and send him to NFC settings else { new AlertDialog.Builder(this).setTitle(R.string.nfc_off_dialog_title) .setMessage(R.string.nfc_off_dialog_message) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS); startActivity(intent); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing, close dialog } }).show(); } } // NFC adapter is null else { new AlertDialog.Builder(this).setTitle(R.string.nfc_off_dialog_title) .setMessage(R.string.nfc_off_dialog_message) .setPositiveButton(R.string.yes_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS); startActivity(intent); } }).setNegativeButton(R.string.no_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing, close dialog } }).show(); } } }
From source file:com.nest5.businessClient.Initialactivity.java
@Override public synchronized void onResume() { super.onResume(); receiver = new WiFiDirectBroadcastReceiver(manager, channel, this); registerReceiver(receiver, intentFilter); registerReceiver(onSyncDownloadComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); SharedPreferences prefs = Util.getSharedPreferences(mContext); String connectionStatus = prefs.getString(Util.CONNECTION_STATUS, Util.DISCONNECTED); prefs.edit().putBoolean(Setup.IS_UPDATING, false); //mReader.start(); // Performing this check in onResume() covers the case in which BT was onResume() // not enabled during onStart(), so we were paused to enable it... onStart() // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.ACTION_REQUEST_ENABLE if (mChatService != null) { // Only if the state is STATE_NONE, do we know that we haven't started already if (mChatService.getState() == BluetoothChatService.STATE_NONE) { // Start the Bluetooth chat services mChatService.start();//from w w w . j av a 2 s. co m } } lay = R.layout.home; setScreenContent(); syncRows = syncRowDataSource.getAllSyncRows(); //////Log.i("SYNC", "syncrows en db: "+String.valueOf(syncRows.size())); if (isConnectedToInternet()) updateMaxSales(); if (deviceText != null) { /** * Print over TCP / IP * * ***/ new connectTask().execute(""); } //Toast.makeText(mContext, String.valueOf(productos.size()) ,Toast.LENGTH_LONG).show(); if (openOtherWindow) { openOtherWindow = false; switch (openOtherWindowAction) { case OPEN_TABLE_ACTION: showCloseTableDialog(); break; default: break; } } }
From source file:com.easemob.chatuidemo.activity.MainActivity.java
/** * ??/*from www. j av a 2s . c o m*/ */ private void registerInternalDebugReceiver() { internalDebugReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { MyApplication.getInstance().logout(new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { public void run() { // ?? finish(); startActivity(new Intent(MainActivity.this, LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { } }); } }; IntentFilter filter = new IntentFilter(getPackageName() + ".em_internal_debug"); registerReceiver(internalDebugReceiver, filter); }
From source file:com.updetector.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /**/*ww w .j a v a2 s .c o m*/ * Set the views */ // Set the main layout setContentView(R.layout.activity_main); // get a handle to the console textview consoleTextView = (TextView) findViewById(R.id.console_text_id); consoleTextView.setMovementMethod(new ScrollingMovementMethod()); //setup monitoring fields environTextView = (TextView) findViewById(R.id.environment); environTextView.setText(ENVIRONMENT_PREFIX + CommonUtils.eventCodeToString(lastEnvironment)); stateTextView = (TextView) findViewById(R.id.state); //stateTextView.setText(STATE_PREFIX+"unknown"); googleStateTextView = (TextView) findViewById(R.id.google_state); googleStateTextView.setText(GOOGLE_MOBILITY_STATE_PREFIX + "unknown"); //indicatorTextView=(TextView) findViewById(R.id.indicator); //indicatorTextView.setText(INDICATOR_PREFIX); // set up the map view setupMapIfNeeded(); //set up the location client setupLocationClientIfNeeded(); /** * set up color coded map */ if (parkingBlocks == null) { parkingBlocks = ParkingBlocks.GetParkingBlocks(); showAvailabilityMap(); } mTextToSpeech = new TextToSpeech(this, this); mCalendar = Calendar.getInstance(); /* * Initialize managers */ // Instantiate an adapter to store update data from the log /* mStatusAdapter = new ArrayAdapter<Spanned>( this, R.layout.item_layout, R.id.log_text );*/ // Set the broadcast receiver intent filer mBroadcastManager = LocalBroadcastManager.getInstance(this); // Create a new Intent filter for the broadcast receiver mBroadcastFilter = new IntentFilter(Constants.ACTION_REFRESH_STATUS_LIST); mBroadcastFilter.addCategory(Constants.CATEGORY_LOCATION_SERVICES); mBroadcastFilter.addAction(Constants.BLUETOOTH_CONNECTION_UPDATE); mBroadcastFilter.addAction(Constants.GOOGLE_ACTIVITY_RECOGNITION_UPDATE); mBroadcastManager.registerReceiver(mBroadcastReceiver, mBroadcastFilter); // Get the instance of the customized notification manager mDetectionNotificationManager = DetectionNotificationManager.getInstance(this); //Get the FusionManager object mFusionManager = new FusionManager(this); // Get the ClassificationManager object mClassificationManager = ClassificationManager.getInstance(this); //TODO train classifiers if necessary if (Constants.IS_TRAINING_MODE) { int[] classifiersToBeTrained = { Constants.ACCEL_MOTION_STATE }; for (int classifier : classifiersToBeTrained) { mClassificationManager.mClassfiers.get(classifier).train(); } } //get the sensor service mSensorManager = (SensorManager) this.getSystemService(SENSOR_SERVICE); //get the accelerometer sensor mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(mSensorEventListener, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); mAudioRecordManager = AudioRecordManager.getInstance(); // Get the WakeLockManager object mWakeLockManager = WakeLockManager.getInstance(this); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // Get the LogManager object mLogManager = LogManager.getInstance(this); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mXPSHandler = new XPS(this); mXPSHandler.setRegistrationUser(new WPSAuthentication("dbmc", "uic")); //mXPSHandler.setTiling("", 0, 0, null); /** * Initialize IODetector */ cellTowerChart = new CellTowerChart((TelephonyManager) getSystemService(TELEPHONY_SERVICE), this); magnetChart = new MagnetChart(mSensorManager, this); lightChart = new LightChart(mSensorManager, this); //new AggregatedIODetector().execute("");//Check the detection for the first time //This timer handle starts the aggregated calculation for the detection //Interval 1 seconds. Timer uiTimer = new Timer(); mIODectorHandler = new Handler(); /*uiTimer.scheduleAtFixedRate(new TimerTask() { private int walked = 0; @Override public void run() { mIODectorHandler.post(new Runnable() { @Override public void run() { if(phoneNotStill){//Check if the user is walking walked++; } else{ walked = 0; } if(aggregationFinish && walked > 3){//Check if the user has walked for at least 3 second, and the previous calculation has been finish aggregationFinish = false; walked = 0; new AggregatedIODetector().execute(""); } } }); } }, 0, 1000);*/ /** * Initialize fields other than managers */ lastAccReading = new double[3]; /** * Startup routines */ // catch the force close error Thread.setDefaultUncaughtExceptionHandler(new UnCaughtException(MainActivity.this)); /** * Start Google Activity Recognition */ mGoogleActivityDetectionRequester = new GoogleActivityRecognitionClientRequester(this); mGoogleActivityDetectionRemover = new GoogleActivityRecognitionClientRemover(this); startGoogleActivityRecognitionUpdates(null); checkGPSEnabled(); //test record sample //mAudioRecordManager.recordAudioSample("/sdcard/audio.wav"); //Test extract features from audio files //String features=AudioFeatureExtraction.extractFeatures(this, "/sdcard/bus6.wav"); //mClassificationManager.mClassfiers.get(Constants.SENSOR_MICROPHONE).classify(features); }
From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java
@Override public void onStart() { super.onStart(); final IntentFilter filter = new IntentFilter(BROADCAST_FRIENDSHIP_CHANGED); filter.addAction(BROADCAST_BLOCKSTATE_CHANGED); filter.addAction(BROADCAST_PROFILE_UPDATED); registerReceiver(mStatusReceiver, filter); updateUserColor();/*from www. jav a 2s .c om*/ }
From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java
@Override protected void onResume() { super.onResume(); Log_OC.e(TAG, "onResume() start"); // Listen for sync messages IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); // Listen for upload messages IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE); mUploadFinishReceiver = new UploadFinishReceiver(); registerReceiver(mUploadFinishReceiver, uploadIntentFilter); // Listen for download messages IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_ADDED_MESSAGE); downloadIntentFilter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE); mDownloadFinishReceiver = new DownloadFinishReceiver(); registerReceiver(mDownloadFinishReceiver, downloadIntentFilter); registerReceiver(instantdownloadreceiver, new IntentFilter(instantDownloadSharedFilesService.NOTIFICATION)); Log_OC.d(TAG, "onResume() end"); }
From source file:com.intel.xdk.device.Device.java
private void registerScreenStatusReceiver() { if (screenStatusReceiver == null) { //Listener to the screen unlock event. screenStatusReceiver = new BroadcastReceiver() { @Override//from ww w . j a va 2 s . c om public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { Log.d("screen_on", "Screen is on."); } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { Log.d("screen_lock", "Screen is off"); String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.device.pause');e.success=true;document.dispatchEvent(e);"; injectJS(js); } else if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) { Log.d("user_present", "User is present."); String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.device.continue');e.success=true;document.dispatchEvent(e);"; injectJS(js); } } }; } IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_USER_PRESENT); activity.registerReceiver(screenStatusReceiver, filter); }
From source file:com.droid.app.fotobot.FotoBot.java
/** * ? ?. ? , battery_level./*from w ww . j a v a 2s . c om*/ */ public void batteryLevel() { BroadcastReceiver batteryLevelReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { //context.unregisterReceiver(this); int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); battery_temperature = ((float) intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1)) / 10.0f; battery_level = -1; if (rawlevel >= 0 && scale > 0) { battery_level = (rawlevel * 100) / scale; } // int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); // isPlugged = plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB; // if (VERSION.SDK_INT > VERSION_CODES.JELLY_BEAN) { // isPlugged = isPlugged || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS; // } } }; IntentFilter batteryLevelFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); registerReceiver(batteryLevelReceiver, batteryLevelFilter); }
From source file:com.intel.xdk.device.Device.java
private void registerBatteryChangeReceiver() { if (batteryChangeReceiver == null) { batteryChangeReceiver = new BroadcastReceiver() { @Override/*from w w w.ja v a 2s. com*/ public void onReceive(Context context, Intent intent) { int batteryStatus = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1); boolean isCharging = batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING || batteryStatus == BatteryManager.BATTERY_STATUS_FULL; if (isCharging) { if (wl == null) { aquireWakeLock(); } } else { if (wl != null) { wl.release(); wl = null; } } } }; } activity.registerReceiver(batteryChangeReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); }
From source file:com.droid.app.fotobot.FotoBot.java
public void sendSMS(String phoneNumber, String message) { String SENT = "SMS_SENT"; String DELIVERED = "SMS_DELIVERED"; PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0); PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0); //---when the SMS has been sent--- registerReceiver(new BroadcastReceiver() { @Override/*from ww w . ja va2 s . c o m*/ public void onReceive(Context arg0, Intent arg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS sent", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(getBaseContext(), "Generic failure", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(getBaseContext(), "No service", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(getBaseContext(), "Radio off", Toast.LENGTH_SHORT).show(); break; } } }, new IntentFilter(SENT)); //---when the SMS has been delivered--- registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS delivered", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not delivered", Toast.LENGTH_SHORT).show(); break; } } }, new IntentFilter(DELIVERED)); SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI); }