IntentFilter addDataScheme - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for IntentFilter addDataScheme method.

This code example shows how to use the following methods:addDataScheme, getDataScheme
 
@RunWith(TestRunners.WithDefaults.class) 
public class IntentFilterTest { 
    @Test 
    public void addDataScheme_shouldAddTheDataScheme() throws Exception { 
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addDataScheme("http");
        intentFilter.addDataScheme("ftp");
 
        assertThat(intentFilter.getDataScheme(0)).isEqualTo("http");
        assertThat(intentFilter.getDataScheme(1)).isEqualTo("ftp");
    } 
     
    @Test 
    public void addDataAuthority_shouldAddTheDataAuthority() throws Exception { 
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addDataAuthority("test.com", "8080");
        intentFilter.addDataAuthority("example.com", "42");
 
        assertThat(intentFilter.getDataAuthority(0).getHost()).isEqualTo("test.com");
9
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme, registerReceiver
    public void onResume() { 
        super.onResume(); 
        updateList(); 
 
        // listen for package changes 
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
        filter.addDataScheme("package");
        getActivity().registerReceiver(mPackageReceiver, filter);
 
        mCR.registerContentObserver(ENABLED_NOTIFICATION_LISTENERS_URI, false, mSettingsObserver);
    } 
 
    @Override 
    public void onPause() { 
        super.onPause(); 
 
8
CodeRank
This code example shows how to use the following methods:registerReceiver, addAction, addDataScheme
 
        public PackageIntentReceiver(AppListLoader loader) {
            mLoader = loader;
            IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
            filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
            filter.addDataScheme("package");
            mLoader.getContext().registerReceiver(this, filter);
            // Register for events related to sdcard installation. 
            IntentFilter sdFilter = new IntentFilter();
            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
            mLoader.getContext().registerReceiver(this, sdFilter);
        } 
 
        @Override public void onReceive(Context context, Intent intent) {
            // Tell the loader about the change. 
            mLoader.onContentChanged();
        } 
    } 
7
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme
 
  public InstalledAppsObserver(AppListLoader loader) {
    mLoader = loader;
 
    // Register for events related to application installs/removals/updates. 
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mLoader.getContext().registerReceiver(this, filter);
 
    // Register for events related to sdcard installation. 
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mLoader.getContext().registerReceiver(this, sdFilter);
  } 
 
  @Override 
  public void onReceive(Context context, Intent intent) {
7
CodeRank
This code example shows how to use the following methods:registerReceiver, addAction, addDataScheme
    public static class PackageIntentReceiver extends BroadcastReceiver {
        final AppListLoader mLoader;
 
        public PackageIntentReceiver(AppListLoader loader) {
            mLoader = loader;
            IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
            filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
            filter.addDataScheme("package");
            mLoader.getContext().registerReceiver(this, filter);
            // Register for events related to sdcard installation. 
            IntentFilter sdFilter = new IntentFilter();
            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
            sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
            mLoader.getContext().registerReceiver(this, sdFilter);
        } 
 
        @Override public void onReceive(Context context, Intent intent) {
            // Tell the loader about the change. 
            mLoader.onContentChanged();
7
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme
            onPackageChanged(); 
        } 
    }; 
 
    private final InputMethodManager mImm;
    private final IntentFilter mIntentFilter = new IntentFilter();
    private final HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>> mRadioViewAndImiMap =
            new HashMap<View, Pair<InputMethodInfo, InputMethodSubtype>>();
    private final TreeMap<InputMethodInfo, List<InputMethodSubtype>>
            mEnabledInputMethodAndSubtypesCache =
                    new TreeMap<InputMethodInfo, List<InputMethodSubtype>>(
                            new InputMethodComparator()); 
 
    private boolean mAttached = false;
    private boolean mPackageChanged = false;
    private Context mContext;
    private IBinder mToken;
    private InputMethodButton mInputMethodSwitchButton;
    private LinearLayout mInputMethodMenuList;
    private boolean mHardKeyboardAvailable;

7
CodeRank
This code example shows how to use the following methods:registerReceiver, addAction, addDataScheme
        } 
 
        // ---------------------------------------------------------------------------------------------------------------------------------- 
        public void register() { 
            if (mFilter == null) {
                mFilter = new IntentFilter();
                mFilter.addAction(Intent.ACTION_MEDIA_EJECT);
                mFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
                mFilter.addDataScheme("file");
                // mFilter.setPriority(500); 
                CmClientUtil.getServiceContext().registerReceiver(this, mFilter);
            } 
        } 
 
        // ---------------------------------------------------------------------------------------------------------------------------------- 
        public void unregister() { 
            if (mFilter != null) {
                CmClientUtil.getServiceContext().unregisterReceiver(this);
                mFilter = null;
            } 
6
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme
                    if (action.equals(Intent.ACTION_MEDIA_EJECT)) {
                        finishNoStorageAvailable(); 
                    } 
                } 
            }; 
            IntentFilter iFilter = new IntentFilter();
            iFilter.addAction(Intent.ACTION_MEDIA_EJECT);
            iFilter.addDataScheme("file");
            registerReceiver(mUnmountReceiver, iFilter);
        } 
    } 
 
 
    private void finishNoStorageAvailable() { 
        setResult(StudyOptions.CONTENT_NO_EXTERNAL_STORAGE);
        finish();
    } 
 
    // ---------------------------------------------------------------------------- 
    // INNER CLASSES 
6
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme
        } 
    } 
 
    @Override 
    protected IntentFilter getBroadcastIntentFilter() {
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
        filter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
        filter.addDataScheme("file");
        return filter;
    } 
 
    @Override 
    protected void updateState(Context context) {
        if (mIsScanning) {
            mIcon = R.drawable.stat_media_scan_on; 
            mState = STATE_ENABLED; 
        } else { 
            mIcon = R.drawable.stat_media_scan_off; 
            mState = STATE_DISABLED; 
6
CodeRank
This code example shows how to use the following methods:addAction, addDataScheme
            } 
        } 
    } 
 
    private void registerIntentReceivers() { 
        IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addDataScheme("package");
        mRegisteredReceiver = new ApplicationsIntentReceiver();
        registerReceiver(mRegisteredReceiver, filter);
    } 
 
    @Override 
    protected void onListItemClick(ListView l, View v, int position, long id) {
        MyPackageInfo info =
            mAdapter.itemForPosition(position);
        if (info != null) {
            Intent intent = new Intent(
                null, Uri.fromParts("package", info.info.packageName, null));
6
CodeRank

Related IntentFilter addDataScheme Questions & Answers:

addDataScheme Method Overview
Add a new Intent data scheme to match against.
See Code Examples for other Android IntentFilter Methods: