Example usage for android.content IntentFilter matchAction

List of usage examples for android.content IntentFilter matchAction

Introduction

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

Prototype

public final boolean matchAction(String action) 

Source Link

Document

Match this filter against an Intent's action.

Usage

From source file:dev.drsoran.moloko.fragments.factories.AbstractIntentFragmentFactory.java

protected final static Fragment resolveIntentToFragment(Context context, Intent intent,
        List<Class<? extends Fragment>> fragmentClasses) {
    Fragment fragment = null;/*from   w ww .  j ava  2s  .c  om*/

    try {
        for (Iterator<Class<? extends Fragment>> i = fragmentClasses.iterator(); i.hasNext()
                && fragment == null;) {
            final Class<? extends Fragment> entry = i.next();

            final IntentFilter filter = (IntentFilter) entry.getMethod("getIntentFilter").invoke(null);

            if (filter.matchAction(intent.getAction()) && filter.matchData(intent.resolveType(context),
                    intent.getScheme(), intent.getData()) > 0) {
                fragment = DefaultFragmentFactory.create(context, entry, intent.getExtras());
            }
        }
    } catch (Throwable e) {
        MolokoApp.Log.e(AbstractIntentFragmentFactory.class,
                "Unable to instantiate new fragment by Intent " + intent, e);
    }

    return fragment;
}