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:at.alladin.rmbt.android.main.RMBTMainActivity.java

/**
* 
*//*from  w w  w. j  a  v a  2 s.  co  m*/
@Override
public void onCreate(final Bundle savedInstanceState) {
    //Log.i("MAIN ACTIVITY", "onCreate");
    restoreInstance(savedInstanceState);
    super.onCreate(savedInstanceState);
    NetworkInfoCollector.init(this);
    networkInfoCollector = NetworkInfoCollector.getInstance();

    preferencesUpdate();
    setContentView(R.layout.main_with_navigation_drawer);

    if (VIEW_HIERARCHY_SERVER_ENABLED) {
        ViewServer.get(this).addWindow(this);
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setDisplayUseLogoEnabled(true);

    // initialize the navigation drawer with the main menu list adapter:
    String[] mainTitles = getResources().getStringArray(R.array.navigation_main_titles);
    int[] navIcons = new int[] { R.drawable.ic_action_home, R.drawable.ic_action_history,
            R.drawable.ic_action_map, R.drawable.ic_action_stat, R.drawable.ic_action_help,
            R.drawable.ic_action_about, R.drawable.ic_action_settings, R.drawable.ic_action_about };

    MainMenuListAdapter mainMenuAdapter = new MainMenuListAdapter(this, mainTitles, navIcons);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerList = (ListView) findViewById(R.id.left_drawer);
    drawerLayout.setBackgroundResource(R.drawable.ic_drawer);

    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer,
            R.string.page_title_title_page, R.string.page_title_title_page) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            //refreshActionBar(null);
            exitAfterDrawerClose = false;
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };

    drawerLayout.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (KeyEvent.KEYCODE_BACK == event.getKeyCode() && exitAfterDrawerClose) {
                onBackPressed();
                return true;
            }
            return false;
        }
    });
    drawerLayout.setDrawerListener(drawerToggle);
    drawerList.setAdapter(mainMenuAdapter);
    drawerList.setOnItemClickListener(new OnItemClickListener() {
        final int[] menuIds = new int[] { R.id.action_title_page, R.id.action_history, R.id.action_map,
                R.id.action_stats, R.id.action_help, R.id.action_info, R.id.action_settings,
                R.id.action_netstat, R.id.action_log };

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectMenuItem(menuIds[position]);
            drawerLayout.closeDrawers();
        }
    });

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // Do something against banding effect in gradients
    // Dither flag might mess up on certain devices??
    final Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
    window.addFlags(WindowManager.LayoutParams.FLAG_DITHER);

    // Setzt Default-Werte, wenn noch keine Werte vorhanden
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    final String uuid = ConfigHelper.getUUID(getApplicationContext());

    fm = getFragmentManager();
    final Fragment fragment = fm.findFragmentById(R.id.fragment_content);
    if (!ConfigHelper.isTCAccepted(this)) {
        if (fragment != null && fm.getBackStackEntryCount() >= 1)
            // clear fragment back stack
            fm.popBackStack(fm.getBackStackEntryAt(0).getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);

        getActionBar().hide();
        setLockNavigationDrawer(true);

        showTermsCheck();
    } else {
        currentMapOptions.put("highlight", uuid);
        if (fragment == null) {
            if (false) // deactivated for si // ! ConfigHelper.isNDTDecisionMade(this))
            {
                showTermsCheck();
                showNdtCheck();
            } else
                initApp(true);
        }
    }

    geoLocation = new MainGeoLocation(getApplicationContext());

    mNetworkStateChangedFilter = new IntentFilter();
    mNetworkStateChangedFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);

    mNetworkStateIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(final Context context, final Intent intent) {
            if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                final boolean connected = !intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY,
                        false);
                final boolean isFailover = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);

                if (connected) {
                    if (networkInfoCollector != null) {
                        networkInfoCollector.setHasConnectionFromAndroidApi(true);
                    }
                } else {
                    if (networkInfoCollector != null) {
                        networkInfoCollector.setHasConnectionFromAndroidApi(false);
                    }
                }

                Log.i(DEBUG_TAG, "CONNECTED: " + connected + " FAILOVER: " + isFailover);
            }
        }
    };
}

From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java

private void registerSmsReceiverIfNeeded() {
    if (!useSmsReceiver) {
        return;/*from  ww w .j  a  v  a  2  s. c  om*/
    }

    if (smsReceiver != null) {
        return;
    }
    Logger.d("registerSmsReceiver");

    smsReceiver = new SmsReceiver(new ISmsReceiver() {
        @Override
        public void onCompleteSms(String code) {
            Logger.d("++ onCompleteSms(%s)", code);
            if (!TextUtils.isEmpty(code)) {
                final String url = String.format(Locale.US, "javascript:insertSms('%s')", code);
                Logger.d("++ command : " + url);
                webView.loadUrl(url);
            }
        }
    });

    IntentFilter filter = new IntentFilter();
    filter.addAction(SmsReceiver.ACTION);
    filter.setPriority(999); // ? SMS  ?? SMS  priority 3  .
    getContext().getApplicationContext().registerReceiver(smsReceiver, filter);
}

From source file:com.java2s.intents4.IntentsDemo4Activity.java

private IntentFilter createFilterFromEditTextFields() {
    IntentFilter filter = new IntentFilter();

    if (filterActionsLayout != null) {
        int count = filterActionsLayout.getChildCount();
        for (int i = 0; i < count; i++) {
            String action = ((EditText) ((ViewGroup) filterActionsLayout.getChildAt(i)).getChildAt(1)).getText()
                    .toString().trim();//  w w  w .j  av a2s. com
            if (action.length() != 0) {
                filter.addAction(action);
            }
        }
    }

    if (filterSchemeLayout != null) {
        int count = filterSchemeLayout.getChildCount();
        for (int i = 0; i < count; i++) {
            String scheme = ((EditText) ((ViewGroup) filterSchemeLayout.getChildAt(i)).getChildAt(1)).getText()
                    .toString().trim();
            if (scheme.length() != 0) {
                filter.addDataScheme(scheme);
            }
        }
    }

    if (filterAuthLayout != null) {
        int count = filterAuthLayout.getChildCount();
        for (int i = 0; i < count; i++) {
            String auth = ((EditText) ((ViewGroup) filterAuthLayout.getChildAt(i)).getChildAt(1)).getText()
                    .toString().trim();
            if (auth.length() != 0) {
                Scanner scanner = new Scanner(auth);
                scanner.useDelimiter(":");
                String host = null;
                String port = null;
                if (scanner.hasNext()) {
                    host = scanner.next();
                }
                if (scanner.hasNext()) {
                    port = scanner.next();
                }
                filter.addDataAuthority(host, port);
            }
        }
    }

    if (filterPathLayout != null) {
        int count = filterPathLayout.getChildCount();
        for (int i = 0; i < count; i++) {

            ViewGroup group = (ViewGroup) filterPathLayout.getChildAt(i);
            String path = ((EditText) group.getChildAt(1)).getText().toString().trim();
            String pattern = ((TextView) ((ViewGroup) group.getChildAt(2)).getChildAt(0)).getText().toString()
                    .trim(); // ((TextView)

            int patternInt = 0;
            if (pattern.equals(pathPatterns[0])) {
                patternInt = PatternMatcher.PATTERN_LITERAL;
            }
            if (pattern.equals(pathPatterns[1])) {
                patternInt = PatternMatcher.PATTERN_PREFIX;
            }
            if (pattern.equals(pathPatterns[2])) {
                patternInt = PatternMatcher.PATTERN_SIMPLE_GLOB;
            }
            if (path.length() != 0) {
                filter.addDataPath(path, patternInt);
            }
        }
    }

    if (filterTypeLayout != null) {
        int count = filterTypeLayout.getChildCount();
        for (int i = 0; i < count; i++) {
            String aType = ((EditText) ((ViewGroup) filterTypeLayout.getChildAt(i)).getChildAt(1)).getText()
                    .toString().trim();
            if (aType.length() != 0) {
                try {
                    filter.addDataType(aType);
                } catch (MalformedMimeTypeException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    if (filterCategoriesLayout != null) {
        int count = filterCategoriesLayout.getChildCount();
        for (int i = 0; i < count; i++) {
            String cat = ((EditText) ((ViewGroup) filterCategoriesLayout.getChildAt(i)).getChildAt(1)).getText()
                    .toString().trim();
            if (cat.length() != 0) {
                filter.addCategory(cat);
            }
        }
    }
    return filter;
}

From source file:com.muggins.test.ble.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);
    intentFilter.addAction(BluetoothLeService.EMOTION);
    return intentFilter;
}

From source file:fr.bmartel.android.dotti.DottiActivity.java

/**
 * add filter to intent to receive notification from bluetooth service
 *
 * @return intent filter/*from   ww w. j a v  a  2  s. c  o m*/
 */
private static IntentFilter makeGattUpdateIntentFilter() {
    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ActionFilterGatt.ACTION_GATT_CONNECTED);
    intentFilter.addAction(ActionFilterGatt.ACTION_GATT_DISCONNECTED);
    intentFilter.addAction(ActionFilterGatt.ACTION_GATT_SERVICES_DISCOVERED);
    intentFilter.addAction(ActionFilterGatt.ACTION_DATA_AVAILABLE);
    return intentFilter;
}

From source file:com.halseyburgund.rwframework.core.RWService.java

/**
 * Creates an IntentFilter for the SUCCESS, FAILURE and QUEUED broadcast
 * intents for all the current server calls.
 * //from  w  w  w. java  2  s .  c  o m
 * @return IntentFilter to receive low level server call broadcasts
 */
public IntentFilter createOperationsIntentFilter() {
    IntentFilter filter = new IntentFilter();
    return addOperationsToIntentFilter(filter, getString(R.string.rw_op_add_asset_to_envelope),
            getString(R.string.rw_op_create_envelope), getString(R.string.rw_op_get_config),
            getString(R.string.rw_op_get_stream), getString(R.string.rw_op_get_tags),
            getString(R.string.rw_op_heartbeat), getString(R.string.rw_op_log_event),
            getString(R.string.rw_op_modify_stream));
}

From source file:com.dragon4.owo.ar_trace.ARCore.MixView.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    DataSource.createIcons(getResources());

    try {/*from   w  w w .ja  v a 2  s  . c  om*/
        // ??
        final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        // ?    ?? ?
        this.mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "My Tag");
        // ?? 
        locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        //  ?? . 2 ?? (1/1000s), 3 ?? (m)? ? 
        locationMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 3, this);

        //orientation sensor 
        sensorMgr_ori = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
        orientationSensor = sensorMgr_ori.getDefaultSensor(Sensor.TYPE_ORIENTATION);

        killOnError(); // ?  ?
        requestWindowFeature(Window.FEATURE_NO_TITLE); // ?   ? 

        //  ?? 
        FrameLayout frameLayout = new FrameLayout(this);

        //  ?    ?, ? 
        frameLayout.setMinimumWidth(3000);
        frameLayout.setPadding(10, 0, 10, 10);

        // ? ? ? ?? ?
        camScreen = new CameraSurface(this);
        augScreen = new AugmentedView(this);
        setContentView(camScreen); // ? ?? ?  ? 

        // ? ?? ? 
        addContentView(augScreen, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        // ? ? ? ?   ?.
        // ? ?  ?  ?? ?  ?  ?
        addContentView(frameLayout, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));

        topLayoutOnMixView = new TopLayoutOnMixView(this);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addContentView(topLayoutOnMixView.mainArView, params);

        // ? ? ? topLayoutOnMixView ?  ?
        handleIntent(getIntent()); // ?? 

        //  ? ? ?
        if (!isInited) {
            mixContext = new MixContext(this); // ? ?
            // ? ?
            mixContext.downloadManager = new DownloadManager(mixContext);

            //? ?  ? 
            navigator = new Navigator(mixContext, topLayoutOnMixView.naverFragment);

            // ? ? ?? ? ?
            dWindow = new PaintScreen();
            dataView = new DataView(mixContext);

            isInited = true; //   true

        }

        if (mixContext.isActualLocation() == false) {
            Toast.makeText(this, getString(DataView.CONNECTION_GPS_DIALOG_TEXT), Toast.LENGTH_LONG).show();
        }

    } catch (Exception ex) {
        doError(ex); //  ? ? 
    }

    //   ? 
    IntentFilter naviBraodFilter = new IntentFilter();
    naviBraodFilter.addAction("NAVI");
    registerReceiver(naviRecevicer, naviBraodFilter);
}

From source file:mp.teardrop.PlaybackService.java

@Override
public void onCreate() {
    HandlerThread thread = new HandlerThread("PlaybackService", Process.THREAD_PRIORITY_DEFAULT);
    thread.start();//from  ww  w  .ja va 2  s .c o  m

    mTimeline = new SongTimeline(this);
    mTimeline.setCallback(this);
    int state = loadState();

    mPlayCounts = new PlayCountsHelper(this);

    mMediaPlayer = getNewMediaPlayer();
    mBastpUtil = new BastpUtil();
    mReadahead = new ReadaheadThread();
    mReadahead.start();

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    SharedPreferences settings = getSettings(this);
    settings.registerOnSharedPreferenceChangeListener(this);
    mNotificationMode = Integer.parseInt(settings.getString(PrefKeys.NOTIFICATION_MODE, "1"));
    mScrobble = settings.getBoolean(PrefKeys.SCROBBLE, false);
    mIdleTimeout = settings.getBoolean(PrefKeys.USE_IDLE_TIMEOUT, false)
            ? settings.getInt(PrefKeys.IDLE_TIMEOUT, 3600)
            : 0;

    Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_ANDROID, true)
            ? Song.mCoverLoadMode | Song.COVER_MODE_ANDROID
            : Song.mCoverLoadMode & ~(Song.COVER_MODE_ANDROID);
    Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_VANILLA, true)
            ? Song.mCoverLoadMode | Song.COVER_MODE_VANILLA
            : Song.mCoverLoadMode & ~(Song.COVER_MODE_VANILLA);
    Song.mCoverLoadMode = settings.getBoolean(PrefKeys.COVERLOADER_SHADOW, true)
            ? Song.mCoverLoadMode | Song.COVER_MODE_SHADOW
            : Song.mCoverLoadMode & ~(Song.COVER_MODE_SHADOW);

    mHeadsetOnly = settings.getBoolean(PrefKeys.HEADSET_ONLY, false);
    mStockBroadcast = settings.getBoolean(PrefKeys.STOCK_BROADCAST, false);
    mInvertNotification = settings.getBoolean(PrefKeys.NOTIFICATION_INVERTED_COLOR, false);
    mNotificationAction = createNotificationAction(settings);
    mHeadsetPause = getSettings(this).getBoolean(PrefKeys.HEADSET_PAUSE, true);
    mShakeAction = settings.getBoolean(PrefKeys.ENABLE_SHAKE, false)
            ? Action.getAction(settings, PrefKeys.SHAKE_ACTION, Action.NextSong)
            : Action.Nothing;
    mShakeThreshold = settings.getInt(PrefKeys.SHAKE_THRESHOLD, 80) / 10.0f;

    mReplayGainTrackEnabled = settings.getBoolean(PrefKeys.ENABLE_TRACK_REPLAYGAIN, false);
    mReplayGainAlbumEnabled = settings.getBoolean(PrefKeys.ENABLE_ALBUM_REPLAYGAIN, false);
    mReplayGainBump = settings.getInt(PrefKeys.REPLAYGAIN_BUMP, 75); /* seek bar is 150 -> 75 == middle == 0 */
    mReplayGainUntaggedDeBump = settings.getInt(PrefKeys.REPLAYGAIN_UNTAGGED_DEBUMP,
            150); /* seek bar is 150 -> == 0 */

    mReadaheadEnabled = settings.getBoolean(PrefKeys.ENABLE_READAHEAD, false);

    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TeardropMusicLock");

    mReceiver = new Receiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    filter.addAction(Intent.ACTION_SCREEN_ON);
    registerReceiver(mReceiver, filter);

    getContentResolver().registerContentObserver(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mObserver);

    CompatIcs.registerRemote(this, mAudioManager);

    mLooper = thread.getLooper();
    mHandler = new Handler(mLooper, this);

    initWidgets();

    updateState(state);
    setCurrentSong(0, false);

    sInstance = this;
    synchronized (sWait) {
        sWait.notifyAll();
    }

    mAccelFiltered = 0.0f;
    mAccelLast = SensorManager.GRAVITY_EARTH;
    setupSensor();
}