List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.saulcintero.moveon.fragments.History.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout fragmentView = (LinearLayout) inflater.inflate(R.layout.history, container, false); act = getActivity();/*from ww w . ja va2 s . c o m*/ mContext = act.getApplicationContext(); res = getResources(); prefs = PreferenceManager.getDefaultSharedPreferences(mContext); editor = prefs.edit(); tracer = LoggerFactory.getLogger(History.class.getSimpleName()); uiHelper = new UiLifecycleHelper(act, callback); uiHelper.onCreate(savedInstanceState); hello_text = (TextView) fragmentView.findViewById(R.id.history_hello_item); distance_text = (TextView) fragmentView.findViewById(R.id.history_item_one); distance_unit_text = (TextView) fragmentView.findViewById(R.id.history_item_nine); sessions_text = (TextView) fragmentView.findViewById(R.id.history_item_two); time_text = (TextView) fragmentView.findViewById(R.id.history_item_three); calories_text = (TextView) fragmentView.findViewById(R.id.history_item_four); historyListView = (ListView) fragmentView.findViewById(R.id.list_routes); refreshRoutes(); intentFilter = new IntentFilter("android.intent.action.REFRESH_ROUTES"); getActivity().registerReceiver(mReceiverRefreshRoutes, intentFilter); intentFilter2 = new IntentFilter("android.intent.action.EXPORT_ROUTES"); getActivity().registerReceiver(mReceiverExportRoutes, intentFilter2); intentFilter3 = new IntentFilter("android.intent.action.EXPORT_AND_SHARE_ROUTES"); getActivity().registerReceiver(mReceiverExportAndShareRoutes, intentFilter3); intentFilter4 = new IntentFilter("android.intent.action.EXPORT_INCREMENT_PROGRESS"); getActivity().registerReceiver(mReceiverIncrementProgress, intentFilter4); intentFilter5 = new IntentFilter("android.intent.action.WRITE_MSG_IN_DIALOG"); getActivity().registerReceiver(mReceiverWriteInProgressDialog, intentFilter5); intentFilter6 = new IntentFilter("android.intent.action.FILTER_ROUTES"); getActivity().registerReceiver(mReceiverFilterRoutes, intentFilter6); intentFilter7 = new IntentFilter("android.intent.action.PUBLISH_TO_FB_WALL"); getActivity().registerReceiver(mReceiverPublishToFbWall, intentFilter7); intentFilter8 = new IntentFilter("android.intent.action.SHOW_OSM_MESSAGE"); getActivity().registerReceiver(mReceiverShowOsmMessage, intentFilter8); intentFilter9 = new IntentFilter("android.intent.action.SHARE_SEND_ACTION"); getActivity().registerReceiver(mReceiverSendAction, intentFilter9); intentFilter10 = new IntentFilter("android.intent.action.IMPORT_ROUTES"); getActivity().registerReceiver(mReceiverImportRoutes, intentFilter10); historyListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long duration) { int sum = 0; for (int p = 0; p < sectionList.size(); p++) { if (p <= position) { if (sectionList.get(p) == 1) sum = sum + 1; } } if (!prefs.getBoolean("blocked", false)) { if (!MoveOnService.getIsPracticeRunning()) { int lastAct = Integer.parseInt(idList.get(position - sum).toString()); editor.putInt("selected_practice", lastAct); editor.commit(); Intent intent = new Intent(act, SummaryHolder.class); startActivity(intent); } else { UIFunctionUtils.showMessage(mContext, false, getString(R.string.route_in_progress)); } } } }); historyListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long duration) { if (!prefs.getBoolean("blocked", false)) { if (!MoveOnService.getIsPracticeRunning()) { int sum = 0; for (int p = 0; p < sectionList.size(); p++) { if (p <= position) { if (sectionList.get(p) == 1) sum = sum + 1; } } int lastAct = Integer.parseInt(idList.get(position - sum).toString()); editor.putInt("selected_practice", lastAct); editor.commit(); UIFunctionUtils.createAlertDialog(act, 1, nameList.get(position - sum).toString()); } else { UIFunctionUtils.showMessage(mContext, false, getString(R.string.end_route_before)); } } return true; } }); return fragmentView; }
From source file:com.taw.gotothere.GoToThereActivity.java
/** * Register the broadcast receiver that listens for locations being set on the * map.//w ww . j a v a 2 s . c om */ private void registerReceiver() { if (receiver == null) { receiver = new NavigationOverlayReceiver(); } IntentFilter filter = new IntentFilter(NavigationOverlay.LOCATION_ON_MAP); registerReceiver(receiver, filter); }
From source file:com.snt.bt.recon.activities.MainActivity.java
private boolean startScan() { //Toast.makeText(getApplicationContext(), "Start scan", Toast.LENGTH_SHORT).show(); logDebug("Activity", "######################## startScan ########################"); final boolean mIsBluetoothOn = mBluetoothUtils.isBluetoothOn(); final boolean mIsBluetoothLePresent = mBluetoothUtils.isBluetoothLeSupported(); //enable bt adapter mBluetoothUtils.getBluetoothAdapter().enable(); //mBluetoothUtils.askUserToEnableBluetoothIfNeeded(); registerReceiver(BluetoothAdapterReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); //BLE//from w ww . ja v a 2 s .c o m mLeDeviceStore.clear(); mLeDeviceListAdapter = new LeDeviceListAdapter(this, mLeDeviceStore.getDeviceCursor()); mList1.setAdapter(mLeDeviceListAdapter); //BC mBcDeviceListAdapter = new BcDeviceListAdapter(this, mBcDeviceList); //BC Addon mList2.setAdapter(mBcDeviceListAdapter); mBcDeviceListAdapter.clear(); if (mIsBluetoothOn && mIsBluetoothLePresent && gpsStatusCheck()) { //sessionid sessionId = UUID.randomUUID(); //save trip to database db.addTrip(new Trip(sessionId, telephonyManager.getDeviceId(), new TransportMode(this).getTransportMode(), getDateTime(), "0", BuildConfig.VERSION_CODE + " (" + BuildConfig.VERSION_NAME + ")", "no")); //BLE mLeScanner.scanLeDevice(-1, true); //BC // Register receiver to get message from BtServiceReceiver registerReceiver(BtScanServiceReceiver, new IntentFilter(BcScanService.ACTION_START_SCAN)); Intent newIntent = new Intent(this, BcScanService.class); newIntent.setAction(BcScanService.ACTION_START_SCAN); newIntent.putExtra(BcScanService.EXTRA_SID, sessionId.toString()); startService(newIntent); BcScanService.IS_SERVICE_RUNNING = true; //reset location id in case old are still stored locationId = null; BcScanService.locationId = null; Toast.makeText(getApplicationContext(), "Starting BC Service...", Toast.LENGTH_SHORT).show(); invalidateOptionsMenu(); return true; } return false; }
From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java
@TargetApi(Build.VERSION_CODES.KITKAT) private Intent registerLocationModeChangeReceiver(CallbackContext callbackContext) { if (locationModeChangeCallbackContext != null) { unregisterLocationModeChangeReceiver(); }/*www. j a va 2 s . c o m*/ locationModeChangeCallbackContext = callbackContext; return getContext().registerReceiver(locationModeChangeReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION)); }
From source file:com.dwdesign.tweetings.fragment.UserListDetailsFragment.java
@Override public void onStart() { mDisplayName = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false); super.onStart(); final IntentFilter filter = new IntentFilter(BROADCAST_USER_LIST_DETAILS_UPDATED); filter.addAction(BROADCAST_USER_LIST_SUBSCRIPTION_CHANGED); registerReceiver(mStatusReceiver, filter); }
From source file:com.hypodiabetic.happ.MainActivity.java
@Override protected void onResume() { super.onResume(); //xdrip start extendedGraphBuilder = new ExtendedGraphBuilder(getApplicationContext()); _broadcastReceiver = new BroadcastReceiver() { @Override/* w ww . j av a 2 s . c om*/ public void onReceive(Context ctx, Intent intent) { if (intent.getAction().compareTo(Intent.ACTION_TIME_TICK) == 0) { setupBGCharts(); displayCurrentInfo(); holdViewport.set(0, 0, 0, 0); } } }; newDataReceiver = new BroadcastReceiver() { @Override public void onReceive(Context ctx, Intent intent) { setupBGCharts(); displayCurrentInfo(); holdViewport.set(0, 0, 0, 0); } }; registerReceiver(_broadcastReceiver, new IntentFilter(Intent.ACTION_TIME_TICK)); registerReceiver(newDataReceiver, new IntentFilter(Intents.ACTION_NEW_BG)); setupBGCharts(); displayCurrentInfo(); holdViewport.set(0, 0, 0, 0); //xdrip end //listens out for new Stats newStatsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); Stats stat = gson.fromJson(intent.getStringExtra("stat"), Stats.class); updateStats(stat); displayCurrentInfo(); } }; registerReceiver(newStatsReceiver, new IntentFilter("ACTION_UPDATE_STATS")); updateStats(null); //listens out for openAPS updates newAPSUpdate = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); APSResult apsResult = gson.fromJson(intent.getStringExtra("APSResult"), APSResult.class); updateOpenAPSDetails(apsResult); setupBGCharts(); displayCurrentInfo(); } }; registerReceiver(newAPSUpdate, new IntentFilter("APS_UPDATE")); //listens out for app notifications appNotification = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int snackbar_length; snackbar_length = intent.getIntExtra("snackbar_length", Snackbar.LENGTH_INDEFINITE); final String alertDialogText = intent.getStringExtra("alertDialogText"); String snackBarMsg = intent.getStringExtra("snackBarMsg"); Snackbar snackbar = Snackbar .make(MainActivity.activity.findViewById(R.id.mainActivity), snackBarMsg, snackbar_length) .setAction("DETAILS", new View.OnClickListener() { @Override public void onClick(View view) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.activity); builder.setMessage(alertDialogText); builder.setPositiveButton("OK", null); builder.show(); } }); snackbar.show(); } }; registerReceiver(appNotification, new IntentFilter("NEW_APP_NOTIFICATION")); }
From source file:it.evilsocket.dsploit.core.UpdateService.java
/** * connect to the notification manager and create a notification builder. * it also setup the cancellation Intent for get notified when our notification got cancelled. */// ww w. j av a 2s . c om private void setupNotification() { // get notification manager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // get notification builder mBuilder = new NotificationCompat.Builder(this); // create a broadcast receiver to get actions // performed on the notification by the user mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) return; // user cancelled our notification if (action.equals(NOTIFICATION_CANCELLED)) { mRunning = false; stopSelf(); } } }; // register our receiver registerReceiver(mReceiver, new IntentFilter(NOTIFICATION_CANCELLED)); // set common notification actions mBuilder.setDeleteIntent( PendingIntent.getBroadcast(this, CANCEL_CODE, new Intent(NOTIFICATION_CANCELLED), 0)); mBuilder.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(), 0)); }
From source file:org.csploit.android.core.UpdateService.java
/** * connect to the notification manager and create a notification builder. * it also setup the cancellation Intent for get notified when our notification got cancelled. *///from w w w .j ava 2 s .c om private void setupNotification() { // get notification manager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // get notification builder mBuilder = new NotificationCompat.Builder(this); // create a broadcast receiver to get actions // performed on the notification by the user mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action == null) return; // user cancelled our notification if (action.equals(NOTIFICATION_CANCELLED)) { mRunning = false; } } }; // register our receiver registerReceiver(mReceiver, new IntentFilter(NOTIFICATION_CANCELLED)); // set common notification actions mBuilder.setDeleteIntent( PendingIntent.getBroadcast(this, CANCEL_CODE, new Intent(NOTIFICATION_CANCELLED), 0)); mBuilder.setContentIntent(PendingIntent.getActivity(this, 0, new Intent(), 0)); }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
@Override public void onStart() { super.onStart(); if (mGoogleApiClient != null) mGoogleApiClient.connect();/*w w w. ja va 2 s. co m*/ // Registering the broadcast receivers //registerReceiver(bReceiver, new IntentFilter(Constants.RECEIVED_RESOURCES_UPDATE)); registerReceiver(mConnReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); registerReceiver(wifiReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); }
From source file:csic.ceab.movelab.beepath.Util.java
public static int getBatteryLevel(Context context) { Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); int level = batteryIntent.getIntExtra("level", -1); int scale = batteryIntent.getIntExtra("scale", -1); // Error checking that probably isn't needed but I added just in case. if (level == -1 || scale == -1) { return -1; }// w w w . j a va2s .c om int powerLevel = (int) Math.round(level * 100.0 / scale); return powerLevel; }