Example usage for android.content IntentFilter addAction

List of usage examples for android.content IntentFilter addAction

Introduction

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

Prototype

public final void addAction(String action) 

Source Link

Document

Add a new Intent action to match against.

Usage

From source file:com.inmovilizaciones.activity.ListarInmovilizacionesActivity.java

@Override
public void onResume() {
    super.onResume();
    try {/*  w w  w  . j  a  v  a  2  s . c  om*/
        setTitle(getString(R.string.listar_inmovilizacion_title));
        if (this.app != null) {
            this.daoSession = this.app.getDaoSession();
        }
        ejecutarConsultaServicios(0, "");
        IntentFilter filter = new IntentFilter();
        filter.addAction(RESPUESTA_SERVICIO);
        registerReceiver(mActualizarListaComparendosBroadcastReceiver, filter);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.hamradiocoin.wallet.service.BlockchainServiceImpl.java

@Override
public void onCreate() {
    serviceCreatedAt = System.currentTimeMillis();
    log.debug(".onCreate()");

    super.onCreate();

    nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    final String lockName = getPackageName() + " blockchain sync";

    final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName);

    application = (WalletApplication) getApplication();
    config = application.getConfiguration();
    final Wallet wallet = application.getWallet();

    bestChainHeightEver = config.getBestChainHeightEver();

    peerConnectivityListener = new PeerConnectivityListener();

    sendBroadcastPeerState(0);/*from w  w w . j  a  v  a2  s.co  m*/

    final IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_LOW);
    intentFilter.addAction(Intent.ACTION_DEVICE_STORAGE_OK);
    registerReceiver(connectivityReceiver, intentFilter);

    blockChainFile = new File(getDir("blockstore", Context.MODE_PRIVATE), Constants.Files.BLOCKCHAIN_FILENAME);
    final boolean blockChainFileExists = blockChainFile.exists();

    if (!blockChainFileExists) {
        log.info("blockchain does not exist, resetting wallet");

        wallet.clearTransactions(0);
        wallet.setLastBlockSeenHeight(-1); // magic value
        wallet.setLastBlockSeenHash(null);
    }

    try {
        blockStore = new SPVBlockStore(Constants.NETWORK_PARAMETERS, blockChainFile);
        blockStore.getChainHead(); // detect corruptions as early as possible

        final long earliestKeyCreationTime = wallet.getEarliestKeyCreationTime();

        if (!blockChainFileExists && earliestKeyCreationTime > 0) {
            try {
                final InputStream checkpointsInputStream = getAssets()
                        .open(Constants.Files.CHECKPOINTS_FILENAME);
                CheckpointManager.checkpoint(Constants.NETWORK_PARAMETERS, checkpointsInputStream, blockStore,
                        earliestKeyCreationTime);
            } catch (final IOException x) {
                log.error("problem reading checkpoints, continuing without", x);
            }
        }
    } catch (final BlockStoreException x) {
        blockChainFile.delete();

        final String msg = "blockstore cannot be created";
        log.error(msg, x);
        throw new Error(msg, x);
    }

    log.info("using " + blockStore.getClass().getName());

    try {
        blockChain = new BlockChain(Constants.NETWORK_PARAMETERS, wallet, blockStore);
    } catch (final BlockStoreException x) {
        throw new Error("blockchain cannot be created", x);
    }

    application.getWallet().addEventListener(walletEventListener, Threading.SAME_THREAD);

    registerReceiver(tickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));

    maybeRotateKeys();
}

From source file:com.andrew.apollo.ui.activities.AudioPlayerActivity.java

/**
 * {@inheritDoc}//from w  w  w  . ja  v  a 2 s . co  m
 */
@Override
protected void onStart() {
    super.onStart();
    final IntentFilter filter = new IntentFilter();
    // Play and pause changes
    filter.addAction(MusicPlaybackService.PLAYSTATE_CHANGED);
    // Shuffle and repeat changes
    filter.addAction(MusicPlaybackService.SHUFFLEMODE_CHANGED);
    filter.addAction(MusicPlaybackService.REPEATMODE_CHANGED);
    // Track changes
    filter.addAction(MusicPlaybackService.META_CHANGED);
    // Update a list, probably the playlist fragment's
    filter.addAction(MusicPlaybackService.REFRESH);
    registerReceiver(mPlaybackStatus, filter);
    // Refresh the current time
    final long next = refreshCurrentTime();
    queueNextRefresh(next);
}

From source file:com.geecko.QuickLyric.MainActivity.java

private void registerTempReceiver() {
    receiver = new MusicBroadcastReceiver();
    MusicBroadcastReceiver.forceAutoUpdate(true);
    IntentFilter intentfilter = new IntentFilter();
    intentfilter.addAction("com.android.music.metachanged");
    intentfilter.addAction("com.htc.music.metachanged");
    intentfilter.addAction("com.miui.player.metachanged");
    intentfilter.addAction("com.real.IMP.metachanged");
    intentfilter.addAction("com.sonyericsson.music.metachanged");
    intentfilter.addAction("com.rdio.android.playstatechanged");
    intentfilter.addAction("com.samsung.sec.android.MusicPlayer.metachanged");
    intentfilter.addAction("com.sec.android.app.music.metachanged");
    intentfilter.addAction("com.nullsoft.winamp.metachanged");
    intentfilter.addAction("com.amazon.mp3.metachanged");
    intentfilter.addAction("com.rhapsody.metachanged");
    intentfilter.addAction("com.maxmpz.audioplayer.metachanged");
    intentfilter.addAction("com.real.IMP.metachanged");
    intentfilter.addAction("com.andrew.apollo.metachanged");
    intentfilter.addAction("fm.last.android.metachanged");
    intentfilter.addAction("com.adam.aslfms.notify.playstatechanged");
    intentfilter.addAction("net.jjc1138.android.scrobbler.action.MUSIC_STATUS");
    intentfilter.addAction("com.spotify.music.metadatachanged");
    registerReceiver(receiver, intentfilter);
    this.receiverRegistered = true;
}

From source file:com.custom.music.MusicBrowserActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, ">>> onCreate", Log.APP);
    setContentView(R.layout.main);//from w  ww .ja  v  a2 s  .  c  om
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(this, this);
    mHasMenukey = ViewConfiguration.get(this).hasPermanentMenuKey();
    mActivityManager = new LocalActivityManager(this, false);
    mActivityManager.dispatchCreate(savedInstanceState);

    mTabHost = getTabHost();
    initTab();
    mCurrentTab = MusicUtils.getIntPref(this, SAVE_TAB, ARTIST_INDEX);
    Log.i(TAG, "onCreate mCurrentTab: " + mCurrentTab, Log.APP);
    if ((mCurrentTab < 0) || (mCurrentTab >= mTabCount)) {
        mCurrentTab = ARTIST_INDEX;
    }
    /// M: reset the defalt tab value
    if (mCurrentTab == ARTIST_INDEX) {
        mTabHost.setCurrentTab(ALBUM_INDEX);
    }
    mTabHost.setOnTabChangedListener(this);

    initPager();
    mViewPager = (ViewPager) findViewById(R.id.viewpage);
    mViewPager.setAdapter(new MusicPagerAdapter());
    mViewPager.setOnPageChangeListener(this);

    //add by zjw
    categories = (TextView) findViewById(R.id.categorisetab);
    categories.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            showPupopMenu(categories);
        }
    });

    IntentFilter f = new IntentFilter();
    f.addAction(MusicUtils.SDCARD_STATUS_UPDATE);
    registerReceiver(mSdcardstatustListener, f);

    createFakeMenu();

    /// M: Init search button click listener in nowplaying.
    //        initSearchButton();

    Log.i(TAG, "onCreate >>>", Log.APP);
}

From source file:com.cerema.cloud2.ui.activity.Uploader.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    prepareStreamsToUpload();//from ww w. jav  a  2 s.c  o m

    if (savedInstanceState == null) {
        mParents = new Stack<String>();
        mAccountSelected = false;
        mAccountSelectionShowing = false;
        mNumCacheFile = 0;

        // ArrayList for files with path in private storage
        mRemoteCacheData = new ArrayList<String>();
    } else {
        mParents = (Stack<String>) savedInstanceState.getSerializable(KEY_PARENTS);
        mFile = savedInstanceState.getParcelable(KEY_FILE);
        mAccountSelected = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTED);
        mAccountSelectionShowing = savedInstanceState.getBoolean(KEY_ACCOUNT_SELECTION_SHOWING);
        mNumCacheFile = savedInstanceState.getInt(KEY_NUM_CACHE_FILE);
        mRemoteCacheData = savedInstanceState.getStringArrayList(KEY_REMOTE_CACHE_DATA);
    }

    super.onCreate(savedInstanceState);

    if (mAccountSelected) {
        setAccount((Account) savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT));
    }

    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(
            RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
}

From source file:com.android.music.MusicBrowserActivity.java

public void onResumeContinue() {
    PDebug.Start("MusicBrowserActivity.onResume");
    MusicLogUtils.d(TAG, "onResume>>>");
    IntentFilter f = new IntentFilter();
    f.addAction(MediaPlaybackService.META_CHANGED);
    registerReceiver(mTrackListListener, f);
    PDebug.Start("MusicBrowserActivity.setCurrentTab()");
    mTabHost.setCurrentTab(mCurrentTab);
    PDebug.End("MusicBrowserActivity.setCurrentTab()");

    PDebug.Start("MusicBrowserActivity.dispatchResume()");
    mActivityManager.dispatchResume();//from  w w  w .j  a  v  a 2 s.  c  om
    PDebug.End("MusicBrowserActivity.dispatchResume()");
    MusicLogUtils.d(TAG, "onResume<<<");
    PDebug.End("MusicBrowserActivity.onResume");
}

From source file:com.github.mjdev.libaums.usbfileman.MainActivity.java

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

    serviceIntent = new Intent(this, UsbFileHttpServerService.class);

    setContentView(R.layout.activity_main);

    listView = (ListView) findViewById(R.id.listview);

    listView.setOnItemClickListener(this);
    registerForContextMenu(listView);//  www  .  jav a 2  s. c  o  m

    IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
    filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
    filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    registerReceiver(usbReceiver, filter);
    discoverDevice();
}

From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java

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

    if (mDrawerLayout != null) {
        final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
        /**/*ww  w. j  a  va  2  s . com*/
         * xinsi
         *
         * Intent.ACTION_PACKAGE_REMOVED:
         * Broadcast Action: An existing application package has been removed from the device.
         *
         * Intent.ACTION_PACKAGE_REPLACED:
         * Broadcast Action: A new version of an application package has been installed,
         * replacing an existing version that was previously installed.
         */
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
        filter.addDataScheme("package");
        registerReceiver(mPackageReceiver, filter);

        new CategoriesUpdater().execute();
    }
    final Intent intent = getIntent();
    if (intent != null) {
        if (intent.hasExtra(EXTRA_SHOW_MENU)) {
            if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {
                // Intent explicitly set to show menu.
                showMenuIcon();
            }
        } else if (isTopLevelTile(intent)) {
            showMenuIcon();
        }
    }
}

From source file:com.freeme.filemanager.FileExplorerTabActivity.java

public void initButtonReceiver() {
    bReceiver = new ButtonBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(ACTION_BUTTON);
    registerReceiver(bReceiver, intentFilter);
}