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.ferdi2005.secondgram.voip.VoIPService.java

@Override
public void onCreate() {
    super.onCreate();
    FileLog.d("=============== VoIPService STARTING ===============");
    AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
            && am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER) != null) {
        int outFramesPerBuffer = Integer
                .parseInt(am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
        VoIPController.setNativeBufferSize(outFramesPerBuffer);
    } else {/*from w  w  w.  j  av  a  2 s.  c o  m*/
        VoIPController.setNativeBufferSize(
                AudioTrack.getMinBufferSize(48000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT)
                        / 2);
    }
    final SharedPreferences preferences = getSharedPreferences("mainconfig", MODE_PRIVATE);
    VoIPServerConfig.setConfig(preferences.getString("voip_server_config", "{}"));
    if (System.currentTimeMillis() - preferences.getLong("voip_server_config_updated", 0) > 24 * 3600000) {
        ConnectionsManager.getInstance().sendRequest(new TLRPC.TL_phone_getCallConfig(), new RequestDelegate() {
            @Override
            public void run(TLObject response, TLRPC.TL_error error) {
                if (error == null) {
                    String data = ((TLRPC.TL_dataJSON) response).data;
                    VoIPServerConfig.setConfig(data);
                    preferences.edit().putString("voip_server_config", data)
                            .putLong("voip_server_config_updated",
                                    BuildConfig.DEBUG ? 0 : System.currentTimeMillis())
                            .apply();
                }
            }
        });
    }
    try {
        controller = new VoIPController();
        controller.setConnectionStateListener(this);
        controller.setConfig(MessagesController.getInstance().callPacketTimeout / 1000.0,
                MessagesController.getInstance().callConnectTimeout / 1000.0,
                preferences.getInt("VoipDataSaving", VoIPController.DATA_SAVING_NEVER));

        cpuWakelock = ((PowerManager) getSystemService(POWER_SERVICE))
                .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "telegram-voip");
        cpuWakelock.acquire();

        btAdapter = am.isBluetoothScoAvailableOffCall() ? BluetoothAdapter.getDefaultAdapter() : null;

        IntentFilter filter = new IntentFilter();
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        filter.addAction(ACTION_HEADSET_PLUG);
        if (btAdapter != null) {
            filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
            filter.addAction(AudioManager.ACTION_SCO_AUDIO_STATE_UPDATED);
        }
        filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
        filter.addAction(getPackageName() + ".END_CALL");
        filter.addAction(getPackageName() + ".DECLINE_CALL");
        filter.addAction(getPackageName() + ".ANSWER_CALL");
        registerReceiver(receiver, filter);

        ConnectionsManager.getInstance().setAppPaused(false, false);

        soundPool = new SoundPool(1, AudioManager.STREAM_VOICE_CALL, 0);
        spConnectingId = soundPool.load(this, R.raw.voip_connecting, 1);
        spRingbackID = soundPool.load(this, R.raw.voip_ringback, 1);
        spFailedID = soundPool.load(this, R.raw.voip_failed, 1);
        spEndId = soundPool.load(this, R.raw.voip_end, 1);
        spBusyId = soundPool.load(this, R.raw.voip_busy, 1);

        am.registerMediaButtonEventReceiver(new ComponentName(this, VoIPMediaButtonReceiver.class));

        if (btAdapter != null && btAdapter.isEnabled()) {
            int headsetState = btAdapter.getProfileConnectionState(BluetoothProfile.HEADSET);
            updateBluetoothHeadsetState(headsetState == BluetoothProfile.STATE_CONNECTED);
            if (headsetState == BluetoothProfile.STATE_CONNECTED)
                am.setBluetoothScoOn(true);
            for (StateListener l : stateListeners)
                l.onAudioSettingsChanged();
        }

        NotificationCenter.getInstance().addObserver(this, NotificationCenter.appDidLogout);
    } catch (Exception x) {
        FileLog.e("error initializing voip controller", x);
        callFailed();
    }
}

From source file:com.ebridgevas.android.ebridgeapp.messaging.mqttservice.MqttAndroidClient.java

private void registerReceiver(BroadcastReceiver receiver) {
    IntentFilter filter = new IntentFilter();
    filter.addAction(MqttServiceConstants.CALLBACK_TO_ACTIVITY);
    LocalBroadcastManager.getInstance(myContext).registerReceiver(receiver, filter);
    receiverRegistered = true;//  w w w .  j ava  2  s  . c om
}

From source file:com.dzt.musicplay.player.AudioService.java

@Override
public void onCreate() {
    super.onCreate();
    GlobalConstants.print_i(getClass(), "onCreate");
    // Get libVLC instance
    try {//  w  w  w  .  ja  v  a2  s  .co  m
        mLibVLC = VLCInstance.getLibVlcInstance(getApplicationContext());
    } catch (LibVlcException e) {
        e.printStackTrace();
    }
    StartLoadFileThread();

    mCallback = new HashMap<IAudioServiceCallback, Integer>();
    mMediaList = new ArrayList<Media>();
    mCurrentIndex = -1;
    mPrevIndex = -1;
    mNextIndex = -1;
    mPrevious = new Stack<Integer>();
    mEventHandler = EventHandler.getInstance();
    mRemoteControlClientReceiverComponent = new ComponentName(getPackageName(),
            RemoteControlClientReceiver.class.getName());

    // Make sure the audio player will acquire a wake-lock while playing. If
    // we don't do
    // that, the CPU might go to sleep while the song is playing, causing
    // playback to stop.
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);

    IntentFilter filter = new IntentFilter();
    filter.setPriority(Integer.MAX_VALUE);
    filter.addAction(ACTION_REMOTE_BACKWARD);
    filter.addAction(ACTION_REMOTE_PLAYPAUSE);
    filter.addAction(ACTION_REMOTE_PLAY);
    filter.addAction(ACTION_REMOTE_PAUSE);
    filter.addAction(ACTION_REMOTE_STOP);
    filter.addAction(ACTION_REMOTE_FORWARD);
    filter.addAction(ACTION_REMOTE_LAST_PLAYLIST);
    filter.addAction(ACTION_WIDGET_INIT);
    filter.addAction(Intent.ACTION_HEADSET_PLUG);
    filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    filter.addAction(SLEEP_INTENT);
    registerReceiver(serviceReceiver, filter);

    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
    boolean stealRemoteControl = pref.getBoolean("enable_steal_remote_control", false);

    if (!LibVlcUtil.isFroyoOrLater() || stealRemoteControl) {
        /* Backward compatibility for API 7 */
        filter = new IntentFilter();
        if (stealRemoteControl)
            filter.setPriority(Integer.MAX_VALUE);
        filter.addAction(Intent.ACTION_MEDIA_BUTTON);
        mRemoteControlClientReceiver = new RemoteControlClientReceiver();
        registerReceiver(mRemoteControlClientReceiver, filter);
    }
    GlobalConstants.print_i(getClass(), "onCreate----end");
}

From source file:com.lewa.crazychapter11.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //set to full screen
    // getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  WindowManager.LayoutParams.FLAG_FULLSCREEN);

    ///set to no title
    // requestWindowFeature(Window.FEATURE_NO_TITLE);
    // acionBar = getSupportActionBar();
    // acionBar = getActionBar();
    // acionBar.hide();

    // Window win = getWindow();
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //          win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
    //          win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
    // win.setStatusBarColor(Color.TRANSPARENT);  
    // win.setNavigationBarColor(Color.TRANSPARENT);

    /*///  ww  w  .jav  a2s  .  c o  m
       win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
       win.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS  | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
       win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN  | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION  | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);  
       win.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);  
       win.setStatusBarColor(Color.TRANSPARENT);  
       win.setNavigationBarColor(Color.TRANSPARENT);
    //*/

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    /* setTheme(R.style.CrazyTheme); */
    AddGameBtn();
    AddNoification();
    LookupContact();
    AddServiceBtn();
    broadcastMain();
    mediaPlayerMain();
    mediaRecordSoundMain();
    cameraMain();
    recordvideoMain();
    queMySql();
    TestFragment();
    justForTest();
    LoadJson();
    AddTestBtn();
    AddUsageStatsBtn();
    AddPeopleProvideBtn();
    getInput();

    ////just for test shutdown broadcast receiver
    IntentFilter mIntentFilter = new IntentFilter("android.intent.action.ACTION_SHUTDOWN");
    mIntentFilter.addAction("com.lewa.alarm.test");
    mIntentFilter.addAction("android.provider.Telephony.SECRET_CODE");
    mIntentFilter.addAction("android.intent.action.SCREEN_ON");
    mIntentFilter.addAction("android.intent.action.SCREEN_OFF");
    mShoutdown = new shutdownReceiver();
    registerReceiver(mShoutdown, mIntentFilter);
    ////test      

    preferences = getSharedPreferences("crazyit", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editor = preferences.edit();

    preferencestime = getSharedPreferences("RMS_Shutdown_time", MODE_WORLD_WRITEABLE | MODE_WORLD_READABLE);
    editortime = preferencestime.edit();

    SharedShutdownTimeRead();

    AddSharedPreBtn();

    etNum = (EditText) findViewById(R.id.etNum);

    // //
    int maxLength = 4;

    InputFilter[] fArray = new InputFilter[1];

    fArray[0] = new InputFilter.LengthFilter(maxLength);

    etNum.setFilters(fArray);
    // //

    calThread = new CalThread();
    calThread.start();

    Log.i("algerheMain", "MainActivity onCreate in!!");
    String page = getString(R.string.str_page, "345", "24");
    Log.i("algerheMain", "page=" + page);

    // /just for test here
    ComponentName comp = getIntent().getComponent();
    show_txt = (EditText) findViewById(R.id.show_txt);
    show_txt.setText(
            "??" + comp.getPackageName() + " \n ??" + comp.getClassName());

    ////MD5 check item
    ///1.IMEI
    TelephonyManager TelephonyMgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    String szImei = TelephonyMgr.getDeviceId();
    String m_szSIMSerialNm = TelephonyMgr.getSimSerialNumber();
    CellLocation m_location = TelephonyMgr.getCellLocation();
    String m_Line1Number = TelephonyMgr.getLine1Number();
    String m_OperatorName = TelephonyMgr.getSimOperatorName();
    Log.i("algerheTelephonyMgr", "szImei=" + szImei);
    Log.i("algerheTelephonyMgr", "m_szSIMSerialNm=" + m_szSIMSerialNm);
    Log.i("algerheTelephonyMgr", "m_location=" + m_location);
    Log.i("algerheTelephonyMgr", "m_Line1Number=" + m_Line1Number);
    Log.i("algerheTelephonyMgr", "m_OperatorName=" + m_OperatorName);

    Log.i("algerheMain01", "szImei=" + szImei);
    Log.i("algerheMain01", "m_szSIMSerialNm=" + m_szSIMSerialNm);

    ///2.Pseudo-Unique ID
    String m_szDevIDShort = "35" + //we make this look like a valid IMEI 
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
            + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
            + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
            + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
            + Build.USER.length() % 10; //13 digits

    Log.i("algerheMain01", "m_szDevIDShort=" + m_szDevIDShort);

    ///3. Android ID
    String m_szAndroidID = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    Log.i("algerheMain01", "m_szAndroidID=" + m_szAndroidID);

    ///4.WLAN MAC Address string
    WifiManager wm = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    String m_szWLANMAC = "unknow_wifi_mac";
    if (wm != null && wm.getConnectionInfo() != null) {
        m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
    }

    Log.i("algerheMain01", "m_szWLANMAC=" + m_szWLANMAC);

    ///5.BT MAC Address string
    BluetoothAdapter m_BluetoothAdapter = null; // Local Bluetooth adapter      
    m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    String m_szBTMAC = m_BluetoothAdapter.getAddress();

    Log.i("algerheMain01", "m_szBTMAC=" + m_szBTMAC);

    ///6.sim serial number .getSimSerialNumber()

    // /

    ///reflect test   
    checkMethod();

    // */
    final Intent alarmIntent = new Intent();
    Log.i("algerheMain00", "isLewaRom=" + isLewaRom(this, alarmIntent));

    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == 0x4567) {
                String languageStr = null;
                String countryStr = null;

                Locale[] locList = Locale.getAvailableLocales();

                for (int i = 0; i < locList.length; i++) {
                    languageStr += locList[i].getLanguage();
                    countryStr += locList[i].getCountry();
                }
                // show_txt = (EditText) findViewById(R.id.show_txt);
                show_txt.setText("" + languageStr + " \n " + countryStr);
            } else if (msg.what == 0x2789) {
                Log.i("algerheAlarm", "send alarm message in time=" + System.currentTimeMillis() + "\n action="
                        + alarmIntent.getAction());

                // sendBroadcast(alarmIntent);
            }
        }
    };

    // String strApkPath = intent.getStringExtra("apkPath");
    //         String strCmd = "pm install -r " + strApkPath;
    //         try {
    //             Process install = Runtime.getRuntime().exec(strCmd);
    //             Log.d(TAG, "install = " + install + ", strCmd =" + strCmd);
    //         }catch (Exception ex){
    //             Log.d(TAG, ex.getMessage());
    //         }   
    // */
}

From source file:com.owncloud.android.ui.activity.FileDisplayActivity.java

@Override
protected void onResume() {
    super.onResume();
    Log_OC.e(TAG, "onResume() start");

    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);

    // Listen for upload messages
    IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
    mUploadFinishReceiver = new UploadFinishReceiver();
    registerReceiver(mUploadFinishReceiver, uploadIntentFilter);

    // Listen for download messages
    IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_ADDED_MESSAGE);
    downloadIntentFilter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
    mDownloadFinishReceiver = new DownloadFinishReceiver();
    registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
    registerReceiver(instantdownloadreceiver, new IntentFilter(instantDownloadSharedFilesService.NOTIFICATION));
    Log_OC.d(TAG, "onResume() end");
}

From source file:cn.ucai.superwechart.activity.ChatActivity.java

private void registerReceiver() {
    IntentFilter filter = new IntentFilter();
    filter.addAction("update_contact_list");
    memberDownlodReceiver = new MemberDownlodReceiver();
    registerReceiver(memberDownlodReceiver, filter);
}

From source file:com.liangxun.yuejiula.huanxin.chat.activity.ChatActivity.java

public void registerBoradcastReceiver() {
    IntentFilter myIntentFilter = new IntentFilter();
    myIntentFilter.addAction("update_group_block");
    ///*w  ww. j a v  a2 s.c  o m*/
    registerReceiver(mBroadcastReceiver, myIntentFilter);
}

From source file:com.fastbootmobile.encore.service.PlaybackService.java

/**
 * Called when the service is created//  w w  w.jav  a2 s. com
 */
@Override
public void onCreate() {
    super.onCreate();
    mListenLogger = new ListenLogger(this);
    mPrefetcher = new Prefetcher(this);

    mCommandsHandlerThread = new HandlerThread("PlaybackServiceCommandsHandler");
    mCommandsHandlerThread.start();

    mCommandsHandler = new CommandHandler(this, mCommandsHandlerThread);

    // Register package manager to receive updates
    mPacManReceiver = new PacManReceiver();
    IntentFilter pacManFilter = new IntentFilter();
    pacManFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    pacManFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    pacManFilter.addDataScheme("package");
    registerReceiver(mPacManReceiver, pacManFilter);

    // Really Google, I'd love to use your new APIs... But they're not working. If you use
    // the new Lollipop metadata system, you lose Bluetooth AVRCP since the Bluetooth
    // package still use the old RemoteController system.
    /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    mRemoteMetadata = new RemoteMetadataManagerv21(this);
    } else*/ {
        mRemoteMetadata = new RemoteMetadataManager(this);
    }

    ProviderAggregator.getDefault().addUpdateCallback(this);

    // Native playback initialization
    mNativeHub = new NativeHub(getApplicationContext());
    mNativeSink = new NativeAudioSink();
    mNativeHub.setSinkPointer(mNativeSink.getPlayer().getHandle());
    mNativeHub.setOnAudioWrittenListener(this);
    mNativeHub.onStart();

    mDSPProcessor = new DSPProcessor(this);
    mDSPProcessor.restoreChain(this);

    // Plugins initialization
    PluginsLookup.getDefault().initialize(getApplicationContext());
    PluginsLookup.getDefault().registerProviderListener(this);

    List<ProviderConnection> connections = PluginsLookup.getDefault().getAvailableProviders();
    for (ProviderConnection conn : connections) {
        if (conn.getBinder(false) != null) {
            assignProviderAudioSocket(conn);
        } else {
            Log.w(TAG, "Cannot assign audio socket to " + conn.getIdentifier() + ", binder is null");
        }
    }

    // Setup
    mIsStopping = false;

    // Bind to all provider
    List<ProviderConnection> providers = PluginsLookup.getDefault().getAvailableProviders();
    for (ProviderConnection pc : providers) {
        try {
            IMusicProvider binder = pc.getBinder(false);
            if (binder != null) {
                binder.registerCallback(mProviderCallback);
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Cannot register callback", e);
        }
    }

    // Register AutoMix manager
    mCallbacks.add(AutoMixManager.getDefault());

    // Setup notification system
    mNotification = new ServiceNotification(this);
    mNotification.setOnNotificationChangedListener(new ServiceNotification.NotificationChangedListener() {
        @Override
        public void onNotificationChanged(ServiceNotification notification) {
            NotificationManagerCompat nmc = NotificationManagerCompat.from(PlaybackService.this);
            if (mIsForeground) {
                notification.notify(nmc);
                mIsForeground = true;
            } else {
                notification.notify(PlaybackService.this);
            }

            BitmapDrawable albumArt = notification.getAlbumArt();
            mRemoteMetadata.setAlbumArt(albumArt);
        }
    });

    // Setup lockscreen remote controls
    mRemoteMetadata.setup();

    // Setup playback wakelock (but don't acquire it yet)
    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "OmniMusicPlayback");

    // Restore preferences
    SharedPreferences prefs = getSharedPreferences(SERVICE_SHARED_PREFS, MODE_PRIVATE);
    mRepeatMode = prefs.getBoolean(PREF_KEY_REPEAT, false);
    mShuffleMode = prefs.getBoolean(PREF_KEY_SHUFFLE, false);

    // TODO: Use callbacks
    // Restore playback queue after one second - we have multiple things to wait here:
    //  - The callbacks of the main app's UI
    //  - The providers connecting
    //  - The providers ready to send us data
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            SharedPreferences queuePrefs = getSharedPreferences(QUEUE_SHARED_PREFS, MODE_PRIVATE);
            mPlaybackQueue.restore(queuePrefs);
            mCurrentTrack = queuePrefs.getInt("current", -1);
            mCurrentTrackLoaded = false;
            mNotification.setHasNext(mPlaybackQueue.size() > 1 || (mPlaybackQueue.size() > 0 && mRepeatMode));
        }
    }, 1000);
}

From source file:com.android.settings.Settings.java

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

    mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
        @Override//from  w  w w.ja  v a2 s .c o m
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            invalidateHeaders();
        }
    };
    mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(mDevelopmentPreferencesListener);
    // SPRD:ADD register receiver.
    ListAdapter listAdapter = getListAdapter();
    if (listAdapter instanceof HeaderAdapter) {
        // add for tab style
        ((HeaderAdapter) listAdapter).flushViewCache();
        // add for tab style
        ((HeaderAdapter) listAdapter).resume();
    }
    // SPRD:ADD update Header
    invalidateHeaders();

    registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    //revo lyq 2014 for advan settings
    if (is_advan_settings) {
        IntentFilter mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
        mIntentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
        registerReceiver(mReceiver, mIntentFilter);
    }

}

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

@Override
protected void onResume() {
    Log_OC.v(TAG, "onResume() start");
    super.onResume();
    // refresh Navigation Drawer account list
    mNavigationDrawerAdapter.updateAccountList();

    // refresh list of files
    refreshListOfFilesFragment();//from  w  w  w .ja v a 2s .co m

    // Listen for sync messages
    IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
    syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
    syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
    mSyncBroadcastReceiver = new SyncBroadcastReceiver();
    registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
    //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver,
    // syncIntentFilter);

    // Listen for upload messages
    IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
    mUploadFinishReceiver = new UploadFinishReceiver();
    registerReceiver(mUploadFinishReceiver, uploadIntentFilter);

    // Listen for download messages
    IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
    downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
    mDownloadFinishReceiver = new DownloadFinishReceiver();
    registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);

    Log_OC.v(TAG, "onResume() end");

}