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(Parcel source) 

Source Link

Usage

From source file:mai.whack.StickyNotesActivity.java

private void enableTagWriteMode() {
    mWriteMode = true;/*from   w ww .  j av a2  s.com*/
    IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED);
    mWriteTagFilters = new IntentFilter[] { tagDetected };
    mNfcAdapter.enableForegroundDispatch(this, mNfcPendingIntent, mWriteTagFilters, null);
}

From source file:com.gelakinetic.mtgfam.activities.MainActivity.java

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

    /* http://stackoverflow.com/questions/13179620/force-overflow-menu-in-actionbarsherlock/13180285
     * /*w  w w  .  j  a v  a 2s  . com*/
     * Open ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java, go to method reserveOverflow
     * Replace the original with:
     * public static boolean reserveOverflow(Context context) { return true; }
     */
    if (DEVICE_VERSION >= DEVICE_HONEYCOMB) {
        try {
            ViewConfiguration config = ViewConfiguration.get(this);
            Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
            if (menuKeyField != null) {
                menuKeyField.setAccessible(true);
                menuKeyField.setBoolean(config, false);
            }
        } catch (Exception ex) {
            // Ignore
        }
    }

    mFragmentManager = getSupportFragmentManager();

    try {
        pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (NameNotFoundException e) {
        pInfo = null;
    }

    if (prefAdapter == null) {
        prefAdapter = new PreferencesAdapter(this);
    }

    int lastVersion = prefAdapter.getLastVersion();
    if (pInfo.versionCode != lastVersion) {
        // Clear the robospice cache on upgrade. This way, no cached values w/o foil prices will exist
        try {
            spiceManager.removeAllDataFromCache();
        } catch (NullPointerException e) {
            // eat it. tasty
        }
        showDialogFragment(CHANGELOGDIALOG);
        prefAdapter.setLastVersion(pInfo.versionCode);
        bounceMenu = lastVersion <= 15; //Only bounce if the last version is 1.8.1 or lower (or a fresh install) 
    }

    File mtr = new File(getFilesDir(), JudgesCornerFragment.MTR_LOCAL_FILE);
    File ipg = new File(getFilesDir(), JudgesCornerFragment.IPG_LOCAL_FILE);
    if (!mtr.exists()) {
        try {
            InputStream in = getResources().openRawResource(R.raw.mtr);
            FileOutputStream fos = new FileOutputStream(mtr);
            IOUtils.copy(in, fos);
        } catch (FileNotFoundException e) {
            Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage());
        } catch (IOException e) {
            Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage());
        }
    }
    if (!ipg.exists()) {
        try {
            InputStream in = getResources().openRawResource(R.raw.ipg);
            FileOutputStream fos = new FileOutputStream(ipg);
            IOUtils.copy(in, fos);
        } catch (FileNotFoundException e) {
            Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage());
        } catch (IOException e) {
            Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage());
        }
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setIcon(R.drawable.sliding_menu_icon);

    SlidingMenu slidingMenu = getSlidingMenu();
    slidingMenu.setBehindWidthRes(R.dimen.sliding_menu_width);
    slidingMenu.setBehindScrollScale(0.0f);
    slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
    slidingMenu.setShadowDrawable(R.drawable.sliding_menu_shadow);
    setSlidingActionBarEnabled(false);
    setBehindContentView(R.layout.fragment_menu);

    me = this;

    boolean autoupdate = prefAdapter.getAutoUpdate();
    if (autoupdate) {
        // Only update the banning list if it hasn't been updated recently
        long curTime = new Date().getTime();
        int updatefrequency = Integer.valueOf(prefAdapter.getUpdateFrequency());
        int lastLegalityUpdate = prefAdapter.getLastLegalityUpdate();
        // days to ms
        if (((curTime / 1000) - lastLegalityUpdate) > (updatefrequency * 24 * 60 * 60)) {
            startService(new Intent(this, DbUpdaterService.class));
        }
    }

    timerHandler = new Handler();
    registerReceiver(endTimeReceiver, new IntentFilter(RoundTimerFragment.RESULT_FILTER));
    registerReceiver(startTimeReceiver, new IntentFilter(RoundTimerService.START_FILTER));
    registerReceiver(cancelTimeReceiver, new IntentFilter(RoundTimerService.CANCEL_FILTER));

    updatingDisplay = false;
    timeShowing = false;

    getSlidingMenu().setOnOpenedListener(new OnOpenedListener() {

        @Override
        public void onOpened() {
            // Close the keyboard if the slidingMenu is opened
            hideKeyboard();
        }
    });

    setContentView(R.layout.fragment_activity);
    getSupportFragmentManager().beginTransaction().replace(R.id.frag_menu, new MenuFragment()).commit();

    showOnePane();
    if (findViewById(R.id.middle_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-large and
        // res/values-sw600dp). If this view is present, then the
        // activity should be in two-pane mode.
        mIsATablet = true;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            mThreePane = true;
        } else {
            mThreePane = false;
        }
    } else {
        mThreePane = false;
        mIsATablet = false;
        if (findViewById(R.id.middle_container) != null) {
            findViewById(R.id.middle_container).setVisibility(View.GONE);
            findViewById(R.id.right_container).setVisibility(View.GONE);
        }
    }

    Intent intent = getIntent();

    if (savedInstanceState == null) {
        try {
            if (intent.getAction().equals(Intent.ACTION_VIEW)) { //apparently this can NPE on 4.3. because why not. if we catch it, launch the default frag
                // handles a click on a search suggestion; launches activity to show word
                Uri u = intent.getData();
                long id = Long.parseLong(u.getLastPathSegment());

                // add a fragment
                Bundle args = new Bundle();
                args.putBoolean("isSingle", true);
                args.putLong("id", id);
                CardViewFragment rlFrag = new CardViewFragment();
                rlFrag.setArguments(args);

                attachSingleFragment(rlFrag, "left_frag", false, false);
                showOnePane();
                hideKeyboard();
            } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
                boolean consolidate = prefAdapter.getConsolidateSearch();
                String query = intent.getStringExtra(SearchManager.QUERY);
                SearchCriteria sc = new SearchCriteria();
                sc.Name = query;
                sc.Set_Logic = (consolidate ? CardDbAdapter.FIRSTPRINTING : CardDbAdapter.ALLPRINTINGS);

                // add a fragment
                Bundle args = new Bundle();
                args.putBoolean(SearchViewFragment.RANDOM, false);
                args.putSerializable(SearchViewFragment.CRITERIA, sc);
                if (mIsATablet) {
                    SearchViewFragment svFrag = new SearchViewFragment();
                    svFrag.setArguments(args);
                    attachSingleFragment(svFrag, "left_frag", false, false);
                } else {
                    ResultListFragment rlFrag = new ResultListFragment();
                    rlFrag.setArguments(args);
                    attachSingleFragment(rlFrag, "left_frag", false, false);
                }
                hideKeyboard();
            } else if (intent.getAction().equals(ACTION_FULL_SEARCH)) {
                attachSingleFragment(new SearchViewFragment(), "left_frag", false, false);
                showOnePane();
            } else if (intent.getAction().equals(ACTION_WIDGET_SEARCH)) {
                attachSingleFragment(new SearchWidgetFragment(), "left_frag", false, false);
                showOnePane();
            } else if (intent.getAction().equals(ACTION_ROUND_TIMER)) {
                attachSingleFragment(new RoundTimerFragment(), "left_frag", false, false);
                showOnePane();
            } else {
                launchDefaultFragment();
            }
        } catch (NullPointerException e) {
            launchDefaultFragment();
        }
    }
}

From source file:com.tenforwardconsulting.cordova.bgloc.BackgroundGeolocationPlugin.java

public Intent registerActionReceiver() {
    if (isActionReceiverRegistered) {
        return null;
    }//from ww w  . j a v  a  2s  .  com

    isActionReceiverRegistered = true;
    return getContext().registerReceiver(actionReceiver, new IntentFilter(Constant.ACTION_FILTER));
}

From source file:com.code.android.vibevault.ShowDetailsScreen.java

@Override
public void onResume() {
    super.onResume();
    getApplicationContext().bindService(new Intent(this, DownloadService.class), onDService, BIND_AUTO_CREATE);
    attachToPlaybackService();// w ww  .  ja v  a2 s  .com
    registerReceiver(TitleReceiver, new IntentFilter(VibeVault.BROADCAST_SONG_TITLE));
    refreshTrackList();
}

From source file:samples.piggate.com.piggateCompleteExample.Activity_Logged.java

@Override
protected void onResume() {
    super.onResume();
    updateUIoffers();//from www  . ja  va2  s . com
    registerReceiver(bReceiver, new IntentFilter("serviceIntent"));
}

From source file:com.nttec.everychan.ui.tabs.TabsTrackerService.java

@Override
public void onCreate() {
    Logger.d(TAG, "TabsTrackerService creating");
    super.onCreate();
    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    settings = MainApplication.getInstance().settings;
    tabsState = MainApplication.getInstance().tabsState;
    tabsSwitcher = MainApplication.getInstance().tabsSwitcher;
    pagesCache = MainApplication.getInstance().pagesCache;
    registerReceiver(broadcastReceiver = new BroadcastReceiver() {
        @Override// w w w.  j a  va2s .co m
        public void onReceive(Context context, Intent intent) {
            Logger.d(TAG, "received BROADCAST_ACTION_CLEAR_SUBSCRIPTIONS");
            clearSubscriptions();
        }
    }, new IntentFilter(BROADCAST_ACTION_CLEAR_SUBSCRIPTIONS));
}

From source file:com.mjhram.ttaxi.login_register.LoginActivity.java

@Override
protected void onResume() {
    super.onResume();
    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(Constants.REGISTRATION_COMPLETE));
}

From source file:com.tenforwardconsulting.cordova.bgloc.BackgroundGeolocationPlugin.java

public Intent registerLocationModeChangeReceiver() {
    if (isLocationModeChangeReceiverRegistered) {
        return null;
    }/*from  ww w. ja  v  a2  s . c om*/

    isLocationModeChangeReceiverRegistered = true;
    return getContext().registerReceiver(locationModeChangeReceiver,
            new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
}

From source file:in.rade.armud.armudclient.MainActivity.java

@Override
protected void onStart() {
    super.onStart();
    mGoogleApiClient.connect();//from w  w w  . j a va  2  s. co m
    if (!mReceiverRegistered) {
        LocalBroadcastManager.getInstance(this).registerReceiver(mMsgFromWearReceiver,
                new IntentFilter(Globals.COMMAND_PATH));
        mReceiverRegistered = true;
    }
}

From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java

/**
 * ??//  w  ww.j a v  a  2 s . co m
 *
 * @param app
 *            app?app??????UI?
 * @param addr
 *            ?
 * @param body
 *            ?
 * @return ?
 */
private void sendSMS(String addr, String body) {

    String regularExpression = "[+*#\\d]+";
    if (!addr.matches(regularExpression)) {
        throw new IllegalArgumentException("address must be digit,*,# or +");
    }

    IntentFilter smsSendIntentFilter = new IntentFilter(SMS_SENT);
    genSendSMSBroadreceiver();
    // ??
    mContext.registerReceiver(mSendSMSBroadcastReceiver, smsSendIntentFilter);

    SmsManager manager = SmsManager.getDefault();
    ArrayList<String> textList = manager.divideMessage(body);
    ArrayList<PendingIntent> smsSendPendingIntentList = genSMSPendingIntentList(textList);
    manager.sendMultipartTextMessage(addr, null, textList, smsSendPendingIntentList, null);
    PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
    result.setKeepCallback(true);
    mCallbackContext.sendPluginResult(result);
}