Example usage for android.content IntentFilter addDataScheme

List of usage examples for android.content IntentFilter addDataScheme

Introduction

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

Prototype

public final void addDataScheme(String scheme) 

Source Link

Document

Add a new Intent data scheme to match against.

Usage

From source file:org.fdroid.fdroid.net.DownloaderService.java

/**
 * Get a prepared {@link IntentFilter} for use for matching this service's action events.
 *
 * @param urlString The full file URL to match.
 * @param action    {@link Downloader#ACTION_STARTED}, {@link Downloader#ACTION_PROGRESS},
 *                  {@link Downloader#ACTION_INTERRUPTED}, or {@link Downloader#ACTION_COMPLETE},
 * @return/*from   w ww. jav  a 2s .  c  o m*/
 */
public static IntentFilter getIntentFilter(String urlString, String action) {
    Uri uri = Uri.parse(urlString);
    IntentFilter intentFilter = new IntentFilter(action);
    intentFilter.addDataScheme(uri.getScheme());
    intentFilter.addDataAuthority(uri.getHost(), String.valueOf(uri.getPort()));
    intentFilter.addDataPath(uri.getPath(), PatternMatcher.PATTERN_LITERAL);
    return intentFilter;
}

From source file:org.fdroid.fdroid.installer.Installer.java

/**
 * Gets an {@link IntentFilter} for matching events from the install
 * process based on the original download URL as a {@link Uri}.
 *//*ww w. ja v a  2 s .c  om*/
public static IntentFilter getInstallIntentFilter(Uri uri) {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Installer.ACTION_INSTALL_STARTED);
    intentFilter.addAction(Installer.ACTION_INSTALL_COMPLETE);
    intentFilter.addAction(Installer.ACTION_INSTALL_INTERRUPTED);
    intentFilter.addAction(Installer.ACTION_INSTALL_USER_INTERACTION);
    intentFilter.addDataScheme(uri.getScheme());
    intentFilter.addDataAuthority(uri.getHost(), String.valueOf(uri.getPort()));
    intentFilter.addDataPath(uri.getPath(), PatternMatcher.PATTERN_LITERAL);
    return intentFilter;
}

From source file:org.fdroid.fdroid.installer.Installer.java

public static IntentFilter getUninstallIntentFilter(String packageName) {
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Installer.ACTION_UNINSTALL_STARTED);
    intentFilter.addAction(Installer.ACTION_UNINSTALL_COMPLETE);
    intentFilter.addAction(Installer.ACTION_UNINSTALL_INTERRUPTED);
    intentFilter.addAction(Installer.ACTION_UNINSTALL_USER_INTERACTION);
    intentFilter.addDataScheme("package");
    intentFilter.addDataPath(packageName, PatternMatcher.PATTERN_LITERAL);
    return intentFilter;
}

From source file:org.videolan.vlc.gui.tv.browser.BaseTvActivity.java

@Override
protected void onResume() {
    super.onResume();
    mIsVisible = true;/*from   w  ww  . j a  va 2  s  . c  o m*/
    //Handle network connection state
    IntentFilter networkFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);

    IntentFilter storageFilter = new IntentFilter(Intent.ACTION_MEDIA_MOUNTED);
    storageFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
    storageFilter.addAction(Intent.ACTION_MEDIA_EJECT);
    storageFilter.addDataScheme("file");
    IntentFilter parsingServiceFilter = new IntentFilter(MediaParsingService.ACTION_SERVICE_ENDED);
    parsingServiceFilter.addAction(MediaParsingService.ACTION_SERVICE_STARTED);

    mRegistering = true;
    LocalBroadcastManager.getInstance(this).registerReceiver(mParsingServiceReceiver, parsingServiceFilter);
    registerReceiver(mExternalDevicesReceiver, storageFilter);
    registerReceiver(mExternalDevicesReceiver, networkFilter);
}

From source file:sample.multithreading.DownloaderActivity.java

@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    getWindow().setFlags(/*from w w w. j a  v  a 2 s .c  o  m*/
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR,
            WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                    | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
    CompatibleActionBar localCompatibleActionBar = getCompatibleActionBar();
    localCompatibleActionBar.requestOverlayMode();
    this.mMainView = getLayoutInflater().inflate(R.layout.fragmenthost, null);
    setContentView(this.mMainView);
    localCompatibleActionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbarbg));
    localCompatibleActionBar.setDisplayUseLogoEnabled(true);
    localCompatibleActionBar.setLogo(R.drawable.picasalogo);
    View localView = getLayoutInflater().inflate(R.layout.progress, null);
    localCompatibleActionBar.setCustomView(localView);
    this.mActionBarProgressText = ((TextView) localView.findViewById(R.id.actionBarProgressText));
    IntentFilter localIntentFilter = new IntentFilter(NetworkDownloadService.BROADCAST_ACTION);
    localIntentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    this.mReceiver = new ResponseReceiver();
    LocalBroadcastManager.getInstance(this).registerReceiver(this.mReceiver, localIntentFilter);
    IntentFilter fragmentIntentFilter = new IntentFilter(ACTION_VIEW_IMAGE);
    fragmentIntentFilter.addDataScheme("http");
    LocalBroadcastManager.getInstance(this).registerReceiver(mIntentReceiver, fragmentIntentFilter);

    fragmentIntentFilter = new IntentFilter(ACTION_ZOOM_IMAGE);
    LocalBroadcastManager.getInstance(this).registerReceiver(mIntentReceiver, fragmentIntentFilter);

    FragmentManager localFragmentManager = getSupportFragmentManager();
    this.mSideBySide = getResources().getBoolean(R.bool.sideBySide);
    this.mHideNavigation = getResources().getBoolean(R.bool.hideNavigation);
    localFragmentManager.addOnBackStackChangedListener(this);
    if (paramBundle == null) {
        FragmentTransaction localFragmentTransaction = localFragmentManager.beginTransaction();
        localFragmentTransaction.add(R.id.fragmentHost, new ThumbnailFragment(), THUMBNAIL_FRAGMENT_TAG);
        localFragmentTransaction.commit();
    } else {
        mFullScreen = paramBundle.getBoolean(EXTRA_FULLSCREEN);
        setFullScreen(mFullScreen);
        mPreviousStackCount = localFragmentManager.getBackStackEntryCount();
    }
}

From source file:com.oasisfeng.nevo.decorators.bundle.BundleDecorator.java

@Override
public void onCreate() {
    final IntentFilter filter = new IntentFilter(ACTION_BUNDLE_EXPAND);
    filter.addAction(ACTION_BUNDLE_CLEAR);
    filter.addDataScheme(SCHEME_BUNDLE);
    registerReceiver(mOnBundleAction, filter);
    mNotificationManager = NotificationManagerCompat.from(getApplication());

    if (!bindService(new Intent(INotificationBundle.class.getName()).setPackage(getPackageName()),
            mBundlesConnection = new ServiceConnection() {

                @Override//from   w  ww .  j ava  2 s. c  om
                public void onServiceConnected(final ComponentName name, final IBinder service) {
                    mBundles = INotificationBundle.Stub.asInterface(service);
                }

                @Override
                public void onServiceDisconnected(final ComponentName name) {
                    /* Should never happen */}
            }, BIND_AUTO_CREATE))
        Log.e(TAG, "Failed to bind bundle service.");
}

From source file:com.nbplus.vbroadlauncher.ShowApplicationActivity.java

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

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    setContentView(R.layout.activity_show_application);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addDataScheme("package");

    showProgressDialog();// w  w  w . j a v a2 s . com
    registerReceiver(mPackageInstallReceiver, filter);
    mLoadAsyncTask = new InstalledApplicationTask(this, mHandler);
    mLoadAsyncTask.execute();

    // ViewPager .
    // ??? ? ? ? .
    mViewPager = (NbplusViewPager) findViewById(R.id.viewPager);
    mIndicator = (LinePageIndicator) findViewById(R.id.indicator);

    mAppPagerAdapter = new AppPagerAdapter(this, getSupportFragmentManager());
    mViewPager.setAdapter(mAppPagerAdapter);
    mViewPager.setSwipeable(true);
    mIndicator.setViewPager(mViewPager);
    mIndicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            Log.d(TAG, ">> page selected position = " + position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
}

From source file:com.amaze.filemanager.fragments.AppsList.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(false);/*w ww  .  ja v  a  2 s.c o m*/
    ic = new IconHolder(getActivity(), true, true);
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    intentFilter.addDataScheme("package");
    getActivity().registerReceiver(br, intentFilter);

}

From source file:co.vanir.indecentxposure.IndecentXposure.java

void start(Context context) {
    //become a real boy!

    IntentFilter packageAddOrRemovedFilter = new IntentFilter();
    packageAddOrRemovedFilter.addAction("android.intent.action.PACKAGE_ADDED");
    packageAddOrRemovedFilter.addAction("android.intent.action.PACKAGE_REMOVED");
    packageAddOrRemovedFilter.addDataScheme("package");
    context.registerReceiver(this, packageAddOrRemovedFilter);

    //if we're here, and the user hasn't yet explicitly acknowledged the risk of their choice
    //  GET ALL UP IN THEIR GRILL.
    boolean userDoesntWantTheirPhoneToWork = SerialOffender.hasXposedInstaller(context);
    if (!SerialOffender.getIgnoredState(context) && userDoesntWantTheirPhoneToWork) {

        //if the user hasn't acknowledged they're probably causing their own bugs by
        //  having xposed installed, and the installer is present, then pop up a fresh
        //  reminder
        IndecentXposure.notify(context, "XposedInstaller detected");
    }//from   w  ww .  j  av  a  2  s.com
}

From source file:net.peterkuterna.android.apps.devoxxfrsched.ui.SessionNotesFragment.java

@Override
public void onResume() {
    super.onResume();

    getLoaderManager().restartLoader(0, null, this);

    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    filter.addDataScheme("package");
    getActivity().registerReceiver(mPackageChangesReceiver, filter);
}