List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:org.wso2.iot.agent.services.NetworkInfoService.java
@Override public void onCreate() { thisInstance = this; if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Creating service"); }// w w w . j av a 2s.c o m mapper = new ObjectMapper(); info = getNetworkInfo(); telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(deviceNetworkStatusListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); if (Constants.WIFI_SCANNING_ENABLED) { // Register broadcast receiver // Broadcast receiver will automatically call when number of wifi connections changed registerReceiver(wifiScanReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); // start scanning wifi startWifiScan(); } }
From source file:org.umit.icm.mobile.gui.ControlActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.controlactivity); WebsiteSuggestButton = (Button) this.findViewById(R.id.suggestWebsite); ServiceSuggestButton = (Button) this.findViewById(R.id.suggestService); scanButton = (Button) this.findViewById(R.id.scanButton); // filterButton = (Button) this.findViewById(R.id.filterButton); // servicesFilterButton = (Button) this.findViewById(R.id.serviceFilterButton); mapSelectionButton = (Button) this.findViewById(R.id.mapSelectionButton); enableTwitterButton = (Button) this.findViewById(R.id.enableTwitterButton); bugReportButton = (Button) this.findViewById(R.id.bugReportButton); aboutButton = (Button) this.findViewById(R.id.aboutButton); scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); try {/*from www . java2 s .co m*/ if (Globals.runtimeParameters.getTwitter().equals("Off")) { enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } else { enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } } catch (RuntimeException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("org.umit.icm.mobile.CONTROL_ACTIVITY")) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); } } }; registerReceiver(receiver, new IntentFilter("org.umit.icm.mobile.CONTROL_ACTIVITY")); WebsiteSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { WebsiteSuggestionDialog websiteSuggestionDialog = new WebsiteSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); websiteSuggestionDialog.show(); } }); ServiceSuggestButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { ServiceSuggestionDialog suggestionDialog = new ServiceSuggestionDialog(ControlActivity.this, "", new OnReadyListener()); suggestionDialog.show(); } }); enableTwitterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { if (Globals.runtimeParameters.getTwitter().equals("Off")) { progressDialog = ProgressDialog.show(ControlActivity.this, getString(R.string.loading), getString(R.string.retrieving_website), true, false); new LaunchBrowser().execute(); TwitterDialog twitterDialog = new TwitterDialog(ControlActivity.this, ""); twitterDialog.show(); enableTwitterButton.setText(getString(R.string.disable_twitter_button)); } else { Globals.runtimeParameters.setTwitter("Off"); enableTwitterButton.setText(getString(R.string.enable_twitter_button)); } } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mapSelectionButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { MapSelectionDialog MapSelectionDialog = new MapSelectionDialog(ControlActivity.this, ""); MapSelectionDialog.show(); } }); /* filterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, WebsiteFilterActivity.class); startActivity(intent); } } ); servicesFilterButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, ServiceFilterActivity.class); startActivity(intent); } } );*/ bugReportButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(ControlActivity.this, BugReportActivity.class); startActivity(intent); } }); aboutButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { String msg = getString(R.string.about_text) + "\n" + getString(R.string.link_to_open_monitor) + "\n" + getString(R.string.link_to_umit) + "\n" + getString(R.string.icons_by); final SpannableString spannableString = new SpannableString(msg); Linkify.addLinks(spannableString, Linkify.ALL); AlertDialog alertDialog = new AlertDialog.Builder(ControlActivity.this).create(); alertDialog.setTitle(getString(R.string.about_button)); alertDialog.setMessage(spannableString); alertDialog.setIcon(R.drawable.umit_128); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } }); scanButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (Globals.scanStatus.equalsIgnoreCase(getString(R.string.scan_on))) { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_on)); Globals.scanStatus = getString(R.string.scan_off); stopService(new Intent(ControlActivity.this, ConnectivityService.class)); } else { scanButton.setText(getString(R.string.scan_text) + " " + getString(R.string.scan_off)); Globals.scanStatus = getString(R.string.scan_on); startService(new Intent(ControlActivity.this, ConnectivityService.class)); } try { Globals.runtimeParameters.setScanStatus(Globals.scanStatus); } catch (RuntimeException e) { e.printStackTrace(); } Context context = getApplicationContext(); CharSequence text = getString(R.string.toast_scan_change) + " " + Globals.scanStatus; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }); }
From source file:com.application.treasurehunt.ScanQRCodeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scan_qrcode); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = getActionBar(); actionBar.setTitle("Treasure Hunt"); actionBar.setSubtitle("Scan a QR code"); }//from w w w . j ava 2 s . c om mScanButton = (Button) findViewById(R.id.scan_qr_code_button); mQuestionReturned = (TextView) findViewById(R.id.scan_content_received); mMapManager = MapManager.get(this); mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mMapDataSource = MapDataDAO.getInstance(this); mMapDataSource.open(); mSettings = getSharedPreferences("UserPreferencesFile", 0); mEditor = mSettings.edit(); //http://developer.android.com/guide/topics/data/data-storage.html#pref mCurrentHuntId = mSettings.getInt("currentHuntId", 0); mCurrentParticipantId = mSettings.getInt("huntParticipantId", 0); Log.i("ScanQRCode", "The hunt retrieved from the editor is: " + mCurrentHuntId); if (savedInstanceState == null) { checkLocationServices(); } ScanQRCodeActivity.this.registerReceiver(mLocationReceiver, new IntentFilter(MapManager.ACTION_LOCATION)); mScanButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mQuestionReturned.setText(""); Intent intent = new Intent(ScanQRCodeActivity.this, ZBarScannerActivity.class); startActivityForResult(intent, 1); } }); }
From source file:cc.softwarefactory.lokki.android.activities.MainActivity.java
@Override protected void onResume() { super.onResume(); Log.e(TAG, "onResume"); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // WAKE_LOCK if (firstTimeLaunch || firstTimeLaunch()) { Log.e(TAG, "onResume - firstTimeLaunch, so avoiding launching services."); return;//w w w.ja v a 2 s .c o m } Log.e(TAG, "onResume - NOT firstTimeLaunch, so launching services."); startServices(); LocalBroadcastManager.getInstance(this).registerReceiver(exitMessageReceiver, new IntentFilter("EXIT")); LocalBroadcastManager.getInstance(this).registerReceiver(switchToMapReceiver, new IntentFilter("GO-TO-MAP")); Log.e(TAG, "onResume - check if dashboard is null"); if (MainApplication.dashboard == null) { Log.e(TAG, "onResume - dashboard was null, get dashboard from server"); ServerApi.getDashboard(getApplicationContext()); } }
From source file:com.google.android.DemoKit.DemoKitActivity.java
/** Called when the activity is first created. */ @Override/* w w w.j a va 2 s. c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = getApplicationContext(); // Toast.makeText(this, "inside onCreate of DemoKitActivity", Toast.LENGTH_SHORT).show(); IntentFilter connFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); mConnReceiver = new ConnBroadcastReceiver(); registerReceiver(mConnReceiver, connFilter); setContentView(R.layout.main); enableControls(true); mNocServiceRequestor = new PeriodicScheduler(new Runnable() { @Override public void run() { if (mNocAccessServiceMessenger != null) { toastHandler("Trying to upload Sensor Data"); // if(mConnReceiver.isConnected) { Message msg = Message.obtain(null, NocMessages.URL_MSG, 0, 0); Bundle msgBundle = new Bundle(); msgBundle.putString("url", "http://98.26.23.101/update.php?req=UI:WLDCTLAB1;FV:1.36;E1:0;EC1:0;E2:0;EC2:0;FL:2937;FC:0;BA:1218;TO:2181;TC:2181;FL20:0;FE:0;BL:0;HTO:0;HTC:0;BP1:0;BP2:0;GF:0;UF:1;IN:0;DT:0;TCF:0;TOF:0"); msg.setData(msgBundle); try { mNocAccessServiceMessenger.send(msg); } catch (RemoteException e) { } } else { toastHandler("mNocAccessServiceMessenger is null!"); } } }, 5000); mBTMsgHandler = new Messenger(new BluetoothMsgHandler()); mAccessoryMsgHandler = new Messenger(new ServiceMsgHandler()); mNocMsgHandler = new Messenger(new ServiceMsgHandler()); }
From source file:csic.ceab.movelab.beepath.MainActivity.java
@Override protected void onResume() { PropertyHolder.useSensorACCELEROMETER(true); PropertyHolder.useSensorGRAVITY(false); PropertyHolder.useSensorMAGNETIC_FIELD(false); PropertyHolder.useSensorGYROSCOPE(false); PropertyHolder.useSensorLINEAR_ACCELERATION(false); PropertyHolder.useSensorORIENTATION(false); PropertyHolder.sensorDelayACCELEROMETER(SensorManager.SENSOR_DELAY_NORMAL); PropertyHolder.sensorDelayGRAVITY(SensorManager.SENSOR_DELAY_NORMAL); PropertyHolder.sensorDelayGYROSCOPE(SensorManager.SENSOR_DELAY_NORMAL); PropertyHolder.sensorDelayLINEAR_ACCELERATION(SensorManager.SENSOR_DELAY_NORMAL); PropertyHolder.sensorDelayMAGNETIC_FIELD(SensorManager.SENSOR_DELAY_NORMAL); PropertyHolder.sensorDelayORIENTATION(SensorManager.SENSOR_DELAY_NORMAL); IntentFilter fixFilter;/*from www. j a v a 2s . c o m*/ fixFilter = new IntentFilter( getResources().getString(R.string.internal_message_id) + Util.MESSAGE_FIX_RECORDED); fixReceiver = new FixReceiver(); registerReceiver(fixReceiver, fixFilter); super.onResume(); }
From source file:cn.edu.szjm.support.http.IgnitedHttp.java
/** * Registers a broadcast receiver with the application context that will take care of updating * proxy settings when failing over between 3G and Wi-Fi. <b>This requires the * {@link Manifest.permission#ACCESS_NETWORK_STATE} permission</b>. * /*from w w w.j a v a 2 s . com*/ * @param context * the context used to retrieve the app context */ public void listenForConnectivityChanges(Context context) { context.getApplicationContext().registerReceiver(new ConnectionChangedBroadcastReceiver(this), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:name.setup.dance.StepService.java
@Override public void onCreate() { Log.i(TAG, "[SERVICE] onCreate"); mScorePostModulo = 50;/*from ww w. ja v a2s . com*/ random = new Random(); generateScorePostValue(); super.onCreate(); mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); showNotification(); // Load settings mSettings = PreferenceManager.getDefaultSharedPreferences(this); mDanceStepAppSettings = new DanceStepAppSettings(mSettings); mState = getSharedPreferences("state", 0); mUtils = Utils.getInstance(); mUtils.setService(this); mUtils.initTTS(); acquireWakeLock(); // Start detecting mStepDetector = new StepDetector(); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); 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(mDanceStepAppSettings, mUtils); mStepDisplayer.setSteps(mSteps = mState.getInt("steps", 0)); mStepDisplayer.addListener(mStepListener); mStepDetector.addStepListener(mStepDisplayer); mPaceNotifier = new PaceNotifier(mDanceStepAppSettings, mUtils); mPaceNotifier.setPace(mPace = mState.getInt("pace", 0)); mPaceNotifier.addListener(mPaceListener); mStepDetector.addStepListener(mPaceNotifier); mDistanceNotifier = new DistanceNotifier(mDistanceListener, mDanceStepAppSettings, mUtils); mDistanceNotifier.setDistance(mDistance = mState.getFloat("distance", 0)); mStepDetector.addStepListener(mDistanceNotifier); mSpeedNotifier = new SpeedNotifier(mSpeedListener, mDanceStepAppSettings, mUtils); mSpeedNotifier.setSpeed(mSpeed = mState.getFloat("speed", 0)); mPaceNotifier.addListener(mSpeedNotifier); mCaloriesNotifier = new CaloriesNotifier(mCaloriesListener, mDanceStepAppSettings, mUtils); mCaloriesNotifier.setCalories(mCalories = mState.getFloat("calories", 0)); mStepDetector.addStepListener(mCaloriesNotifier); mSpeakingTimer = new SpeakingTimer(mDanceStepAppSettings, mUtils); mSpeakingTimer.addListener(mStepDisplayer); mSpeakingTimer.addListener(mPaceNotifier); mSpeakingTimer.addListener(mDistanceNotifier); mSpeakingTimer.addListener(mSpeedNotifier); mSpeakingTimer.addListener(mCaloriesNotifier); mStepDetector.addStepListener(mSpeakingTimer); // 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.ginstr.android.service.opencellid.upload.data.MeasurementsUploaderService.java
@Override public void onCreate() { super.onCreate(); mLibContext = OpenCellIdLibContext.getInstance() == null ? new OpenCellIdLibContext(getApplicationContext()) : OpenCellIdLibContext.getInstance(); writeToLog("MeasurementsUploaderService onCreate()"); // android.os.Debug.waitForDebugger(); registerReceiver(configurationReceiver, new IntentFilter(UploadConstants.CONFIGURATION_ACTION)); }
From source file:com.skubit.android.transactions.TransactionsFragment.java
@Override public void onResume() { super.onResume(); String account = mAccountSettings.retrieveBitIdAccount(); if (!TextUtils.isEmpty(account)) { mTransactionService = new TransactionService(new Account(account, "com.google"), getActivity()); refreshBalance();/* ww w . j av a 2 s.c o m*/ getTransactions(); } LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mAccountChangeReceiver, new IntentFilter("account")); }