List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter(Parcel source)
From source file:com.omt.syncpad.DemoKitActivity.java
/** Called when the activity is first created. */ @Override/*w w w . j a v a 2s. c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory); } setContentView(R.layout.main); enableControls(false); }
From source file:net.networksaremadeofstring.rhybudd.WriteNFCActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(WriteNFCActivity.this, "44a76a8c"); setContentView(R.layout.write_tag_activity); try {// w w w. j a va2s. c om getActionBar().setSubtitle(getString(R.string.NFCTitle)); getActionBar().setDisplayHomeAsUpEnabled(true); } catch (Exception gab) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate", gab); } //Quick test try { UID = getIntent().getExtras().getString(PAYLOAD_UID).replace("/zport/dmd/Devices/", ""); aaRecord = NdefRecord.createApplicationRecord("net.networksaremadeofstring.rhybudd"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //idRecord = NdefRecord.createExternal("rhybudd:tag", "z", UID.getBytes(Charset.forName("US-ASCII"))); idRecord = NdefRecord.createMime("application/vnd.rhybudd.device", UID.getBytes()); } else { idRecord = NdefRecord.createUri("rhybudd://" + UID); } ((TextView) findViewById(R.id.SizesText)).setText("This payload is " + (aaRecord.toByteArray().length + idRecord.toByteArray().length) + " bytes.\n\nAn ultralight can store up to 46 bytes.\nAn Ultralight C or NTAG203 can store up to 137 bytes.\nDespite the name a 1K can only store up to 716 bytes."); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate", e); try { Toast.makeText(this, "Sorry there was error parsing the passed UID, we cannot continue.", Toast.LENGTH_SHORT).show(); } catch (Exception t) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate", t); } finish(); } try { mAdapter = NfcAdapter.getDefaultAdapter(this); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate getDefaultAdapter", e); mAdapter = null; } try { pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate pendingIntent", e); } IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndef.addDataType("*/*"); /* Handles all MIME based dispatches. You should specify only the ones that you need. */ } catch (IntentFilter.MalformedMimeTypeException e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate", e); throw new RuntimeException("fail", e); } try { IntentFilter td = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); intentFiltersArray = new IntentFilter[] { ndef, td }; techListsArray = new String[][] { new String[] { NfcF.class.getName(), NfcA.class.getName(), Ndef.class.getName(), NdefFormatable.class.getName() } }; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("WriteNFCActivity", "onCreate IntentFilter", e); } CreateHandlers(); }
From source file:com.sanjaydalvi.spacestationlocator.MainActivity.java
@Override public void onResume() { super.onResume(); MainActivity.this.registerReceiver(receiver, new IntentFilter(ACTION_FOR_INTENT_CALLBACK)); }
From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java
@Override public void onResume() { // onResume is called after onActivityCreated, when the fragment is loaded 100% Log.e(TAG, "onResume"); super.onResume(); if (map == null) { Log.e(TAG, "Map null. creating it."); setUpMap();//from w w w . j a va2s. c o m setupAddPlacesOverlay(); } else { Log.e(TAG, "Map already exists. Nothing to do."); } LocalBroadcastManager.getInstance(context).registerReceiver(mMessageReceiver, new IntentFilter("LOCATION-UPDATE")); LocalBroadcastManager.getInstance(context).registerReceiver(placesUpdateReceiver, new IntentFilter("PLACES-UPDATE")); checkLocationServiceStatus(); new UpdateMap().execute(MapUserTypes.All); cancelAsyncTasks = false; if (MainApplication.places != null) { updatePlaces(); } }
From source file:gpsalarm.app.service.PostMonitor.java
@Override public void onCreate() { super.onCreate(); sdb = new TimelineHelper(this); rdb = new ReminderHelper(this); //get user account from preference. prefs = PreferenceManager.getDefaultSharedPreferences(this); team = prefs.getString("team", "").toUpperCase(); myAccount = new Account(prefs.getString("user", null), prefs.getString("password", ""), null); registerReceiver(onBatteryChanged, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, OnAlarmReceiver.class); pi = PendingIntent.getBroadcast(this, 0, i, 0); setAlarm(INITIAL_POLL_PERIOD);//w ww . j ava2s. c o m }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mTickersContainer = (FixedGridView) getView().findViewById(R.id.tickersContainer); mTickersContainer.setExpanded(true); final int dashboardSpacing = getResources().getDimensionPixelSize(R.dimen.dashboard_spacing); final int dashboardItemSize = getResources().getDimensionPixelSize(R.dimen.dashboard_item_size); mTickersContainer.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override/*from w ww . j a v a 2s. c o m*/ public void onGlobalLayout() { if (mTickersDashboardAdapter.getNumColumns() == 0) { final int numColumns = (int) Math .floor(mTickersContainer.getWidth() / (dashboardSpacing + dashboardItemSize)); if (numColumns > 0) { mTickersDashboardAdapter.setNumColumns(numColumns); mTickersContainer.setNumColumns(numColumns); } } } }); mTickersDashboardAdapter = new TickersDashboardAdapter(getActivity(), this); updateStorageWithTickers(); mTickersDashboardAdapter.update(); mTickersContainer.setAdapter(mTickersDashboardAdapter); TextView emptyView = (TextView) getView().findViewById(R.id.emptyView); mTickersContainer.setEmptyView(emptyView); mTickersContainer.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return event.getAction() == MotionEvent.ACTION_MOVE; } }); //Broadcast receiver initialization mGetStatsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (isVisible()) { if (mRefreshItem != null) { mRefreshItem.collapseActionView(); mRefreshItem.setActionView(null); } mTickersDashboardAdapter.update(); } } }; LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(mGetStatsReceiver, new IntentFilter("UpdateTickers")); //Trade listener, once "Buy" or "Sell" clicked, send the order to server View.OnClickListener tradeListener = new View.OnClickListener() { @Override public void onClick(View v) { new RegisterTradeRequestTask().execute((v.getId() == R.id.BuyButton) ? "buy" : "sell"); } }; Button SellButton = (Button) getView().findViewById(R.id.SellButton); Button BuyButton = (Button) getView().findViewById(R.id.BuyButton); SellButton.setOnClickListener(tradeListener); BuyButton.setOnClickListener(tradeListener); Button UpdateAccountInfoButton = (Button) getView().findViewById(R.id.UpdateAccountInfoButton); UpdateAccountInfoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new UpdateFundsTask().execute(); } }); //start service to get new data once Dashboard is opened getActivity().sendBroadcast(new Intent(getActivity(), StartServiceReceiver.class)); }
From source file:com.poloure.simplerss.FeedsActivity.java
@Override protected void onResume() { super.onResume(); setServiceIntent(ALARM_SERVICE_STOP); registerReceiver(m_broadcastReceiver, new IntentFilter(ServiceUpdate.BROADCAST_ACTION)); // Update the navigation adapter. This updates the subtitle and title. if (s_fragmentWeb.isHidden()) { AsyncNavigationAdapter.run(this); }//from www .ja v a2 s .c o m // Update the state of the pullToRefresh progress bar. s_pullToRefreshLayout.setRefreshing(isServiceRunning()); }
From source file:jp.app_mart.billing.AppmartHelper.java
/** * appmart???//from w ww .j a v a 2s . c o m * @param listener Activity?callback */ public void startSetup(final OnAppmartSetupFinishedListener listener) { if (mSetupDone) throw new IllegalStateException(mContext.getString(R.string.already_connected)); mServiceConn = new ServiceConnection() { //? public void onServiceConnected(ComponentName name, IBinder boundService) { mService = AppmartInBillingInterface.Stub.asInterface((IBinder) boundService); mSetupDone = true; if (listener != null) { listener.onAppmartSetupFinished(new AppmartResult(BILLING_RESPONSE_RESULT_OK, mContext.getString(R.string.is_now_connected))); } //????receiver IntentFilter filter = new IntentFilter("appmart_broadcast_return_service_payment"); if (mReceiver == null) mReceiver = new AppmartReceiver(); mContext.registerReceiver(mReceiver, filter); } //? public void onServiceDisconnected(ComponentName name) { logDebug(mContext.getString(R.string.is_now_deconnected)); mService = null; } }; Intent serviceIntent = new Intent(); serviceIntent.setClassName(BILLING_APPMART_PACKAGE_NAME, BILLING_APPMART_SERVICE_NAME); //?appmart???????? if (!mContext.getPackageManager().queryIntentServices(serviceIntent, 0).isEmpty()) { mContext.bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE); } else { if (listener != null) { listener.onAppmartSetupFinished(new AppmartResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, mContext.getString(R.string.appmart_not_installed))); } } }
From source file:com.precisosol.llgeofence.GeofencePlugin.java
@Override public PluginResult execute(String action, JSONArray data, String callback) { Looper.myLooper().prepare();/*from www. j ava 2s . c o m*/ PluginResult result = null; if (action.equalsIgnoreCase(INITIALIZE_SERVICE)) { try { receiver = new GeofenceReceiver(); ctx.registerReceiver(receiver, new IntentFilter(GEOFENCE_FIRED)); ctx.registerReceiver(receiver, new IntentFilter(AUTH_SUCCESS)); ctx.registerReceiver(receiver, new IntentFilter(AUTH_FAILURE)); // create our ServiceConnection serviceConnection = new ServiceConnection() { public void onServiceConnected(ComponentName name, IBinder service) { mService = ((GeofenceService.ServiceBinder) service).getService(); mService.setConsumerKeyAndSecret(CONSUMER_KEY, CONSUMER_SECRET); mService.setAuthorizationActions(AUTH_SUCCESS, AUTH_FAILURE, GeofenceReceiver.class); mService.authorize(); mService.enable(); } public void onServiceDisconnected(ComponentName name) { // geofences still persist mService = null; } }; if (!(ctx.bindService(new Intent(ctx, GeofenceService.class), serviceConnection, Context.BIND_AUTO_CREATE))) { Log.w(LOG, "Failed to bind to GeofenceService"); } result = new PluginResult(PluginResult.Status.OK, "Service start signal sent."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(CREATE_GEOFENCE)) { try { int externalIdentifier = data.getInt(0); //identifier to identify the related object internally double latitude = data.getDouble(1); double longitude = data.getDouble(2); float radius = (float) data.getDouble(3); int crossingType = data.getInt(4); Geofence g = AddGeofence(latitude, longitude, radius, crossingType); org.yajl.JSONObject tmp = new org.yajl.JSONObject(g); tmp.append("EID", externalIdentifier); String str = tmp.toString(); tmp = null; Log.d("Service_Output", str); JSONObject resultobject = new JSONObject(str); str = null; result = new PluginResult(PluginResult.Status.OK, resultobject); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(DELETE_GEOFENCE)) { try { long id = data.getLong(0); DeleteGeofence(id); result = new PluginResult(PluginResult.Status.OK, "Geofence deleted successfully."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(DELETE_ALL_GEOFENCES)) { try { DeleteAllGeofences(); result = new PluginResult(PluginResult.Status.OK, "Geofences deleted successfully."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(FIND_GEOFENCE)) { try { long id = data.getLong(0); Geofence g = FindGeofence(id); org.yajl.JSONObject tmp = new org.yajl.JSONObject(g); String str = tmp.toString(); tmp = null; Log.d("Service_Output", str); JSONObject resultobject = new JSONObject(str); str = null; result = new PluginResult(PluginResult.Status.OK, resultobject); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(GET_ALL_GEOFENCES)) { try { ArrayList<Geofence> geofences = GetAllGeofences(); org.yajl.JSONArray tmp = new org.yajl.JSONArray(geofences); String str = tmp.toString(); tmp = null; Log.d("Service_Output", str); JSONArray resultobject = new JSONArray(str); str = null; result = new PluginResult(PluginResult.Status.OK, resultobject); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(GET_CURRENT_LOCATION)) { try { if (mService != null) { Thread.sleep(5000); Location loc = location; org.yajl.JSONObject obj = new org.yajl.JSONObject(loc); JSONObject resultobject = new JSONObject(obj.toString()); result = new PluginResult(PluginResult.Status.OK, resultobject); } else { result = new PluginResult(PluginResult.Status.ERROR, "Service not running."); } } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(GET_LAST_KNOWN_LOCATION)) { try { if (mService != null) { Location loc = mService.getLastKnownLocation(); org.yajl.JSONObject obj = new org.yajl.JSONObject(loc); JSONObject resultobject = new JSONObject(obj.toString()); result = new PluginResult(PluginResult.Status.OK, resultobject); } } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(SET_CALLBACKS)) { try { AUTH_SUCCESS_CALLBACK = data.getString(0); AUTH_FAILURE_CALLBACK = data.getString(1); GEOFENCE_ENTRY_CALLBACK = data.getString(2); GEOFENCE_EXIT_CALLBACK = data.getString(3); SERVICE_FAILURE_CALLBACK = data.getString(4); result = new PluginResult(Status.OK, "Callbacks setup Successfully."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(ENABLE)) { try { mService.enable(); result = new PluginResult(Status.OK, "Service Enabled Successfully."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } else if (action.equalsIgnoreCase(DISABLE)) { try { mService.disable(); result = new PluginResult(Status.OK, "Service Disabled Successfully."); } catch (Exception e) { result = new PluginResult(Status.ERROR, e.getMessage()); } } return result; }
From source file:com.cellbots.remoteEyes.RemoteEyesActivity.java
/** Called when the activity is first created. */ @Override//w w w . j a v a2s . c o m public void onCreate(Bundle savedInstanceState) { Log.e("remote eyes", "started"); super.onCreate(savedInstanceState); mTorchMode = false; out = new ByteArrayOutputStream(); if ((getIntent() != null) && (getIntent().getData() != null)) { putUrl = getIntent().getData().toString(); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); Bundle extras = getIntent().getExtras(); if ((extras != null) && (extras.getBoolean("TORCH", false))) { mTorchMode = true; } } else { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); putUrl = prefs.getString("REMOTE_EYES_PUT_URL", ""); Log.e("prefs", putUrl); if (putUrl.length() < 1) { Intent i = new Intent(); i.setClass(this, PrefsActivity.class); startActivity(i); finish(); return; } else { server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); } } resetConnection(); mHttpState = new HttpState(); setContentView(R.layout.main); mPreview = (SurfaceView) findViewById(R.id.preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); this.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); setTorchMode(useTorch); } }, new IntentFilter("android.intent.action.REMOTE_EYES_COMMAND")); }