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:com.easemob.chatuidemo.activity.MainActivity.java

public void setXG() {
    BroadcastReceiver receiver = new BroadcastReceiver() {

        @Override/* w  w  w  . ja  v a 2s. c o  m*/
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            System.out.println("hahahhahahah");
        }

    };
    IntentFilter intent = new IntentFilter();
    intent.addAction("bobo.com");
    this.registerReceiver(receiver, intent);
    Handler handler = new HandlerExtension(this);
    m = handler.obtainMessage();

    XGPushManager.registerPush(getApplicationContext(), Preferences.getUserName(), new XGIOperateCallback() {

        @Override
        public void onSuccess(Object arg0, int arg1) {
            // TODO Auto-generated method stub
            System.out.println("?");
            m.sendToTarget();
        }

        @Override
        public void onFail(Object arg0, int arg1, String arg2) {
            // TODO Auto-generated method stub
            m.sendToTarget();
            System.out.println("");
        }
    });
}

From source file:com.ichi2.anki.AbstractFlashcardViewer.java

/**
 * Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver)
 *///ww  w. j  a  va2 s  .  c om
private void registerExternalStorageListener() {
    if (mUnmountReceiver == null) {
        mUnmountReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
                    finishWithoutAnimation();
                }
            }
        };
        IntentFilter iFilter = new IntentFilter();
        iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
        registerReceiver(mUnmountReceiver, iFilter);
    }
}

From source file:com.hichinaschool.flashcards.anki.CardBrowser.java

/**
 * Show/dismiss dialog when sd card is ejected/remounted (collection is saved by SdCardReceiver)
 *///from   w  w w . j  a v a2s  .c  o  m
private void registerExternalStorageListener() {
    if (mUnmountReceiver == null) {
        mUnmountReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals(SdCardReceiver.MEDIA_EJECT)) {
                    finish();
                }
            }
        };
        IntentFilter iFilter = new IntentFilter();
        iFilter.addAction(SdCardReceiver.MEDIA_EJECT);
        registerReceiver(mUnmountReceiver, iFilter);
    }
}

From source file:com.mobicage.rogerthat.plugins.messaging.BrandingMgr.java

public void initialize(ConfigurationProvider cfgProvider, MainService mainService) {
    T.UI();/*from ww w. j  a  v  a2s.c o m*/
    mCfgProvider = cfgProvider;
    mMainService = mainService;
    mContext = mainService;

    List<BrandedItem> copy = new ArrayList<BrandingMgr.BrandedItem>();
    Collections.copy(mQueue, copy);
    for (BrandedItem item : copy)
        if (item.status != BrandedItem.STATUS_TODO)
            dequeue(item, false);

    mDownloaderThread = new HandlerThread("rogerthat_branding_worker");
    mDownloaderThread.start();
    Looper looper = mDownloaderThread.getLooper();
    mDownloaderHandler = new Handler(looper);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    mContext.registerReceiver(mBroadcastReceiver, filter);
    initStorageSettings();

    mInitialized = true;

    mMainService.postOnBIZZHandler(new SafeRunnable() {
        @Override
        protected void safeRun() throws Exception {
            if (mMainService.getPluginDBUpdates(BrandingMgr.class).contains(MUST_DELETE_ATTACHMENTS_INTENT)) {
                synchronized (mLock) {
                    IOUtils.deleteRecursive(getAttachmentsRootDirectory());
                }
                mMainService.clearPluginDBUpdate(BrandingMgr.class, MUST_DELETE_ATTACHMENTS_INTENT);
            }
        }
    });
}

From source file:com.android.server.MountService.java

/**
 * Constructs a new MountService instance
 *
 * @param context  Binder context for this service
 *///from   w w w .  j av  a2 s.  c  om
public MountService(Context context) {
    sSelf = this;

    mContext = context;

    synchronized (mVolumesLock) {
        readStorageListLocked();
    }

    // XXX: This will go away soon in favor of IMountServiceObserver
    mPms = (PackageManagerService) ServiceManager.getService("package");

    HandlerThread hthread = new HandlerThread(TAG);
    hthread.start();
    mHandler = new MountServiceHandler(hthread.getLooper());

    // Watch for user changes
    final IntentFilter userFilter = new IntentFilter();
    userFilter.addAction(Intent.ACTION_USER_ADDED);
    userFilter.addAction(Intent.ACTION_USER_REMOVED);
    mContext.registerReceiver(mUserReceiver, userFilter, null, mHandler);

    // Watch for USB changes on primary volume
    final StorageVolume primary = getPrimaryPhysicalVolume();
    if (primary != null && primary.allowMassStorage()) {
        mContext.registerReceiver(mUsbReceiver, new IntentFilter(UsbManager.ACTION_USB_STATE), null, mHandler);
    }

    // Add OBB Action Handler to MountService thread.
    mObbActionHandler = new ObbActionHandler(IoThread.get().getLooper());

    // Initialize the last-fstrim tracking if necessary
    File dataDir = Environment.getDataDirectory();
    File systemDir = new File(dataDir, "system");
    mLastMaintenanceFile = new File(systemDir, LAST_FSTRIM_FILE);
    if (!mLastMaintenanceFile.exists()) {
        // Not setting mLastMaintenance here means that we will force an
        // fstrim during reboot following the OTA that installs this code.
        try {
            (new FileOutputStream(mLastMaintenanceFile)).close();
        } catch (IOException e) {
            Slog.e(TAG, "Unable to create fstrim record " + mLastMaintenanceFile.getPath());
        }
    } else {
        mLastMaintenance = mLastMaintenanceFile.lastModified();
    }

    /*
     * Create the connection to vold with a maximum queue of twice the
     * amount of containers we'd ever expect to have. This keeps an
     * "asec list" from blocking a thread repeatedly.
     */
    mConnector = new NativeDaemonConnector(this, "vold", MAX_CONTAINERS * 2, VOLD_TAG, 25, null);

    Thread thread = new Thread(mConnector, VOLD_TAG);
    thread.start();

    // Add ourself to the Watchdog monitors if enabled.
    if (WATCHDOG_ENABLE) {
        Watchdog.getInstance().addMonitor(this);
    }
}