Example usage for android.content IntentFilter IntentFilter

List of usage examples for android.content IntentFilter IntentFilter

Introduction

In this page you can find the example usage for android.content IntentFilter IntentFilter.

Prototype

public IntentFilter() 

Source Link

Document

New empty IntentFilter.

Usage

From source file:com.t2.compassionMeditation.DeviceManagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mInstance = this;
    sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    //this.sendBroadcast(new Intent(BioFeedbackService.ACTION_SERVICE_START));

    this.setContentView(R.layout.device_manager_activity_layout);

    this.findViewById(R.id.bluetoothSettingsButton).setOnClickListener(this);

    Resources resources = this.getResources();
    AssetManager assetManager = resources.getAssets();
    try {/*from   w w  w  .jav a  2 s  . c  o m*/
        mSpineManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources);
    } catch (InstantiationException e) {
        Log.e(TAG, this.getClass().getSimpleName() + " Exception creating SPINE manager: " + e.toString());
        e.printStackTrace();
    }
    // ... then we need to register a SPINEListener implementation to the SPINE manager instance
    // to receive sensor node data from the Spine server
    // (I register myself since I'm a SPINEListener implementation!)
    mSpineManager.addListener(this);

    // Create a broadcast receiver. Note that this is used ONLY for command messages from the service
    // All data from the service goes through the mail SPINE mechanism (received(Data data)).
    // See public void received(Data data)
    this.mCommandReceiver = new SpineReceiver(this);
    // Set up filter intents so we can receive broadcasts
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.t2.biofeedback.service.status.BROADCAST");
    filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    filter.addAction(BioFeedbackService.ACTION_STATUS_BROADCAST);

    this.registerReceiver(this.mCommandReceiver, filter);

    // Tell the bluetooth service to send us a list of bluetooth devices and system status
    // Response comes in public void onStatusReceived(BioFeedbackStatus bfs) STATUS_PAIRED_DEVICES      
    mSpineManager.pollBluetoothDevices();

    //      this.deviceManager = DeviceManager.getInstance(this.getBaseContext(), null);
    this.deviceList = (ListView) this.findViewById(R.id.list);

    this.deviceListAdapter = new ManagerItemAdapter(this, R.layout.manager_item);
    this.deviceList.setAdapter(this.deviceListAdapter);

    this.bluetoothDisabledDialog = new AlertDialog.Builder(this).setMessage("Bluetooth is not enabled.")
            .setOnCancelListener(new OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            }).setPositiveButton("Setup Bluetooth", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    startBluetoothSettings();
                }
            }).create();

    try {
        PackageManager packageManager = this.getPackageManager();
        PackageInfo info = packageManager.getPackageInfo(this.getPackageName(), 0);
        mVersionName = info.versionName;
        Log.i(TAG, this.getClass().getSimpleName() + " Spine server Test Application Version " + mVersionName);
    } catch (NameNotFoundException e) {
        Log.e(TAG, this.getClass().getSimpleName() + e.toString());
    }
}

From source file:com.android.development.Connectivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.connectivity);

    mWm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mPm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
    mNetd = INetworkManagementService.Stub.asInterface(b);

    findViewById(R.id.enableWifi).setOnClickListener(mClickListener);
    findViewById(R.id.disableWifi).setOnClickListener(mClickListener);

    findViewById(R.id.startDelayedCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopDelayedCycle).setOnClickListener(mClickListener);
    mDCOnDurationEdit = (EditText) findViewById(R.id.dc_wifi_on_duration);
    mDCOnDurationEdit.setText(Long.toString(mDCOnDuration));
    mDCOffDurationEdit = (EditText) findViewById(R.id.dc_wifi_off_duration);
    mDCOffDurationEdit.setText(Long.toString(mDCOffDuration));
    mDCCycleCountView = (TextView) findViewById(R.id.dc_wifi_cycles_done);
    mDCCycleCountView.setText(Integer.toString(mDCCycleCount));

    findViewById(R.id.startScreenCycle).setOnClickListener(mClickListener);
    findViewById(R.id.stopScreenCycle).setOnClickListener(mClickListener);
    mSCOnDurationEdit = (EditText) findViewById(R.id.sc_wifi_on_duration);
    mSCOnDurationEdit.setText(Long.toString(mSCOnDuration));
    mSCOffDurationEdit = (EditText) findViewById(R.id.sc_wifi_off_duration);
    mSCOffDurationEdit.setText(Long.toString(mSCOffDuration));
    mSCCycleCountView = (TextView) findViewById(R.id.sc_wifi_cycles_done);
    mSCCycleCountView.setText(Integer.toString(mSCCycleCount));

    mScanButton = (Button) findViewById(R.id.startScan);
    mScanButton.setOnClickListener(mClickListener);
    mScanCyclesEdit = (EditText) findViewById(R.id.sc_scan_cycles);
    mScanCyclesEdit.setText(Long.toString(mScanCycles));
    mScanDisconnect = (CheckBox) findViewById(R.id.scanDisconnect);
    mScanDisconnect.setChecked(true);/*from   w w  w .j av a2s  . c  om*/
    mScanResults = (TextView) findViewById(R.id.sc_scan_results);
    mScanResults.setVisibility(View.INVISIBLE);

    mScanRecv = new WifiScanReceiver();
    mIntentFilter = new IntentFilter();
    mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

    findViewById(R.id.startTdls).setOnClickListener(mClickListener);
    findViewById(R.id.stopTdls).setOnClickListener(mClickListener);

    findViewById(R.id.start_mms).setOnClickListener(mClickListener);
    findViewById(R.id.stop_mms).setOnClickListener(mClickListener);
    findViewById(R.id.start_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.stop_hipri).setOnClickListener(mClickListener);
    findViewById(R.id.crash).setOnClickListener(mClickListener);

    findViewById(R.id.add_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.remove_default_route).setOnClickListener(mClickListener);
    findViewById(R.id.bound_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.bound_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_http_request).setOnClickListener(mClickListener);
    findViewById(R.id.routed_socket_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_request).setOnClickListener(mClickListener);
    findViewById(R.id.default_socket).setOnClickListener(mClickListener);

    registerReceiver(mReceiver, new IntentFilter(CONNECTIVITY_TEST_ALARM));
}

From source file:com.hichinaschool.flashcards.anki.StudyOptionsActivity.java

/**
 * Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver)
 */// ww  w  .j  a va2  s.c o  m
private void registerExternalStorageListener() {
    if (mUnmountReceiver == null) {
        mUnmountReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
                    mNotMountedDialog = StyledOpenCollectionDialog.show(StudyOptionsActivity.this,
                            getResources().getString(R.string.sd_card_not_mounted), new OnCancelListener() {

                                @Override
                                public void onCancel(DialogInterface arg0) {
                                    finish();
                                }
                            });
                } else if (intent.getAction().equals(SdCardReceiver.MEDIA_MOUNT)) {
                    if (mNotMountedDialog != null && mNotMountedDialog.isShowing()) {
                        mNotMountedDialog.dismiss();
                    }
                    mCurrentFragment.reloadCollection();
                }
            }
        };
        IntentFilter iFilter = new IntentFilter();
        iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
        iFilter.addAction(SdCardReceiver.MEDIA_MOUNT);
        registerReceiver(mUnmountReceiver, iFilter);
    }
}

From source file:com.google.android.gcm.demo.app.BluetoothHDPActivity.java

private IntentFilter initIntentFilter() {
    IntentFilter filter = new IntentFilter();
    filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    return filter;
}

From source file:com.anykey.balala.activity.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    receiver = new LocalRouterReceiver(new LocalRouterReceiver.RouterCallback() {
        @Override//from   w  w w .j a  v a 2  s.  c  o m
        public void onHandle(byte[] parcel, Object obj) {
            int type = new WillProtocol().getType(parcel);
            byte[] msgByte = new WillProtocol().getData(parcel);
            String msgStr = new String(msgByte).trim();
            if (type == WillOutProtocol.BROADCAST_TYPE_VALUE) {//??
                SystemNotificationModel.SystemBroadcast commonData = JsonUtil.fromJson(msgStr,
                        SystemNotificationModel.SystemBroadcast.class);
                if (commonData.code == 4) {//??
                    String str = commonData.msg;
                    int VersionCode = Integer.valueOf(str.split("%-%")[0]);
                    String message = String.valueOf(str.split("%-%")[1]);
                    int force = commonData.data.force;
                    String AppURL = commonData.data.url;
                    if (Integer.valueOf(versionCode) < VersionCode) {
                        UploadApp uploadApp = new UploadApp(
                                FileUtil.getSDCardDir(MainActivity.this, AppBalala.FILEPATH_UPAPK));
                        uploadApp.showUpApk(MainActivity.this, message, AppURL, force);
                        if (force == 1) {
                            sp.saveUpLoadApk(true, String.valueOf(VersionCode), message, AppURL);
                        }
                    }
                }
            }
        }
    });
    IntentFilter filter = new IntentFilter();
    filter.addAction(RouterProcess.ACTION_ROUTER_PARCEL);
    LocalBroadcastManager.getInstance(MainActivity.this).registerReceiver(receiver, filter);
    if (!sp.getApkInfo_version().equals("")) {
        int ApkVersion = Integer.valueOf(sp.getApkInfo_version());
        if (ApkVersion > Integer.valueOf(versionCode)) {//?
            UploadApp uploadApp = new UploadApp(
                    FileUtil.getSDCardDir(MainActivity.this, AppBalala.FILEPATH_UPAPK));
            uploadApp.showUpApk(MainActivity.this, sp.getApkInfo_message(), sp.getApkInfo_Url(), 1);
        }
    }
}

From source file:hackathon.openrice.CardsActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Bundle extras = getIntent().getExtras();
    String keyword = null;//from   w  ww  .j a  va  2 s . c  o m
    if (extras != null) {
        ArrayList<String> text = extras.getStringArrayList(RecognizerIntent.EXTRA_RESULTS);
        if (text != null) {
            for (String t : text) {
                String temp = t.toLowerCase().trim();
                if (temp.startsWith("search")) {
                    keyword = temp.substring(6).trim();
                }
            }
        }
    }
    Card info = new Card(this);
    info.setText("Loading data...");
    cards.add(info);
    RetrieveImage task = new RetrieveImage();

    // listener passed over to locationProvider, any location update is handled here
    this.locationListener = new LocationListener() {

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        @Override
        public void onProviderEnabled(String provider) {
        }

        @Override
        public void onProviderDisabled(String provider) {
        }

        @Override
        public void onLocationChanged(final Location location) {
            // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy
            if (location != null) {
                // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project)
                lastKnownLocation = location;
                if (lastKnownLocation != null) {
                    // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information)
                    if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) {
                        lastKnownLocation = location;
                    } else {
                        lastKnownLocation = location;
                    }
                }
            }
        }
    };
    locationProvider = new LocationProvider(this, locationListener);
    double x, y;
    if (lastKnownLocation != null) {
        x = lastKnownLocation.getLatitude();
        y = lastKnownLocation.getLongitude();
    } else {
        x = 22.3049989;
        y = 114.17925600000001;
    }
    if (keyword != null) {
        //Log.d("FFFF", keyword);
        task.execute(
                "http://openricescraper.herokuapp.com/?x=" + x + "&y=" + y + "&keyword=" + Uri.encode(keyword));
    } else {
        task.execute("http://openricescraper.herokuapp.com/?x=" + x + "&y=" + y);

    }
    mCardScroller = new CardScrollView(this);
    mCardScroller.setAdapter(new CardAdapter(cards));
    mCardScroller.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            final String className = "com.wikitude.samples.SampleCamActivity";

            try {

                final Intent intent = new Intent(ctx, Class.forName(className));
                intent.putExtra(EXTRAS_KEY_ACTIVITY_TITLE_STRING, "5.2 Adding Radar");
                intent.putExtra(EXTRAS_KEY_ACTIVITY_ARCHITECT_WORLD_URL,
                        "samples/5_Browsing$Pois_2_Adding$Radar/index.html");
                if (poiData != null) {
                    JSONArray pass = new JSONArray();
                    final String ATTR_ID = "id";
                    final String ATTR_NAME = "name";
                    final String ATTR_DESCRIPTION = "description";
                    final String ATTR_LATITUDE = "latitude";
                    final String ATTR_LONGITUDE = "longitude";
                    final String ATTR_ALTITUDE = "altitude";
                    int i = position - 1;
                    //for (int i = 0; i <  poiData.length(); i++) {
                    JSONObject jsonObj = (JSONObject) poiData.get(i);
                    final HashMap<String, String> poiInformation = new HashMap<String, String>();
                    poiInformation.put(ATTR_ID, String.valueOf(i));
                    poiInformation.put(ATTR_NAME,
                            new String(jsonObj.getString("name").getBytes("ISO-8859-1"), "UTF-8"));
                    if (jsonObj.getString("score").equalsIgnoreCase("null")) {
                        poiInformation.put(ATTR_DESCRIPTION,
                                new String(jsonObj.getString("address").getBytes("ISO-8859-1"), "UTF-8"));
                    } else {
                        poiInformation.put(ATTR_DESCRIPTION, "" + jsonObj.getDouble("score") + ", "
                                + new String(jsonObj.getString("address").getBytes("ISO-8859-1"), "UTF-8"));
                    }
                    poiInformation.put(ATTR_LATITUDE, String.valueOf(jsonObj.get("x")));
                    poiInformation.put(ATTR_LONGITUDE, String.valueOf(jsonObj.get("y")));
                    final float UNKNOWN_ALTITUDE = -32768f; // equals "AR.CONST.UNKNOWN_ALTITUDE" in JavaScript (compare AR.GeoLocation specification)
                    // Use "AR.CONST.UNKNOWN_ALTITUDE" to tell ARchitect that altitude of places should be on user level. Be aware to handle altitude properly in locationManager in case you use valid POI altitude value (e.g. pass altitude only if GPS accuracy is <7m).
                    poiInformation.put(ATTR_ALTITUDE, String.valueOf(UNKNOWN_ALTITUDE));
                    pass.put(new JSONObject(poiInformation));
                    //}   
                    intent.putExtra("poiData", pass.toString());
                }

                /* launch activity */
                ctx.startActivity(intent);

            } catch (Exception e) {
                /*
                 * may never occur, as long as all SampleActivities exist and are
                 * listed in manifest
                 */
                Toast.makeText(ctx, className + "\nnot defined/accessible", Toast.LENGTH_SHORT).show();
            }

        }
    });

    setContentView(mCardScroller);
    IntentFilter filter = new IntentFilter();
    filter.addAction("com.ours.asyncisover");
    filter.addCategory("android.intent.category.DEFAULT");
    registerReceiver(myBroadcastReceiver, filter);
    isReceiverRegistered = true;

}

From source file:com.example.bluetoothlegatt.DeviceControlActivity.java

private static IntentFilter makeGattUpdateIntentFilter() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED);
    intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED);
    intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED);
    intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE);
    return intentFilter;
}

From source file:com.nordicsemi.nrfUARTv2.MainActivity.java

private static IntentFilter makeGattUpdateIntentFilter() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(UartService.ACTION_GATT_CONNECTED);
    intentFilter.addAction(UartService.ACTION_GATT_DISCONNECTED);
    intentFilter.addAction(UartService.ACTION_GATT_SERVICES_DISCOVERED);
    intentFilter.addAction(UartService.ACTION_DATA_AVAILABLE);
    intentFilter.addAction(UartService.DEVICE_DOES_NOT_SUPPORT_UART);
    return intentFilter;
}

From source file:hackathon.openrice.CardsActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (!isReceiverRegistered) {
        IntentFilter filter = new IntentFilter();
        filter.addAction("com.ours.asyncisover");
        filter.addCategory("android.intent.category.DEFAULT");
        registerReceiver(myBroadcastReceiver, filter);
        isReceiverRegistered = true;/*from www  . j  a  v  a  2s . co  m*/
    }
    mCardScroller.activate();
}