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.freerdp.freerdpcore.presentation.SessionActivity.java

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

    // show status bar or make fullscreen?
    if (GlobalSettings.getHideStatusBar())
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.setContentView(R.layout.session);
    rladvertising = (AdvertisingView) findViewById(R.id.advertising);
    rladvertising.startImagePlay();//from  w  w w .j  av  a2 s .  c o  m
    final View activityRootView = findViewById(R.id.session_root_view);
    //
    activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            screen_width = activityRootView.getWidth();
            screen_height = activityRootView.getHeight();
            if (!sessionRunning && getIntent() != null) {
                thread = new Thread(SessionActivity.this);
                thread.start();
                sessionRunning = true;
            }
        }
    });

    sessionView = (SessionView) findViewById(R.id.sessionView);
    sessionView.setScaleGestureDetector(new ScaleGestureDetector(this, new PinchZoomListener()));
    sessionView.setSessionViewListener(this);
    sessionView.requestFocus();

    touchPointerView = (TouchPointerView) findViewById(R.id.touchPointerView);
    touchPointerView.setTouchPointerListener(this);

    keyboardMapper = new KeyboardMapper();
    keyboardMapper.init(this);
    keyboardMapper.reset(this);

    modifiersKeyboard = new Keyboard(getApplicationContext(), R.xml.modifiers_keyboard);
    specialkeysKeyboard = new Keyboard(getApplicationContext(), R.xml.specialkeys_keyboard);
    numpadKeyboard = new Keyboard(getApplicationContext(), R.xml.numpad_keyboard);
    cursorKeyboard = new Keyboard(getApplicationContext(), R.xml.cursor_keyboard);

    // hide keyboard below the sessionView
    keyboardView = (KeyboardView) findViewById(R.id.extended_keyboard);
    keyboardView.setKeyboard(specialkeysKeyboard);
    keyboardView.setOnKeyboardActionListener(this);

    modifiersKeyboardView = (KeyboardView) findViewById(R.id.extended_keyboard_header);
    modifiersKeyboardView.setKeyboard(modifiersKeyboard);
    modifiersKeyboardView.setOnKeyboardActionListener(this);

    scrollView = (ScrollView2D) findViewById(R.id.sessionScrollView);
    scrollView.setScrollViewListener(this);
    uiHandler = new UIHandler();
    libFreeRDPBroadcastReceiver = new LibFreeRDPBroadcastReceiver();

    zoomControls = (ZoomControls) findViewById(R.id.zoomControls);
    zoomControls.hide();
    zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomInEnabled(sessionView.zoomIn(ZOOMING_STEP));
            zoomControls.setIsZoomOutEnabled(true);
        }
    });
    zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            resetZoomControlsAutoHideTimeout();
            zoomControls.setIsZoomOutEnabled(sessionView.zoomOut(ZOOMING_STEP));
            zoomControls.setIsZoomInEnabled(true);
        }
    });

    toggleMouseButtons = false;

    createDialogs();

    // register freerdp events broadcast receiver
    IntentFilter filter = new IntentFilter();
    filter.addAction(GlobalApp.ACTION_EVENT_FREERDP);
    registerReceiver(libFreeRDPBroadcastReceiver, filter);

    mClipboardManager = ClipboardManagerProxy.getClipboardManager(this);
    mClipboardManager.addClipboardChangedListener(this);

}

From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java

public void onResume() {
    super.onResume();
    //register bluetooth receiver
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
    intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED);

    registerReceiver(mBroadcastReceiver, intentFilter);
}

From source file:com.polyvi.xface.extension.XAppExt.java

private void registerInstallerReceiver(final XCallbackContext callbackCtx) {
    if (null == mInstallerReceiver) {
        mInstallerReceiver = new BroadcastReceiver() {
            @Override//from w w w  .ja  v a2s  . com
            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")
                        && (uninstallPackageName.equals(intent.getDataString().substring(8)))) {
                    XExtensionResult result = new XExtensionResult(XExtensionResult.Status.OK);
                    callbackCtx.sendExtensionResult(result);
                }
                if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
                    XExtensionResult result = new XExtensionResult(XExtensionResult.Status.OK);
                    callbackCtx.sendExtensionResult(result);
                }
            }
        };
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addDataScheme("package");
        getContext().registerReceiver(mInstallerReceiver, filter);
    }
}

From source file:me.spadival.podmode.PodModeService.java

@Override
public void onCreate() {

    IntentFilter usbFilter = new IntentFilter();
    usbFilter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    usbFilter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
    registerReceiver(mUsbReceiver, usbFilter);
    // mProvider = RemoteMetadataProvider.getInstance(this);

    // mProvider.setOnMetadataChangeListener(mMetadataListner);
    // mProvider.acquireRemoteControls();
    LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this);
    IntentFilter notifyFilter = new IntentFilter();
    notifyFilter.addAction(NOTIFYACTION);
    bManager.registerReceiver(mNotifyReceiver, notifyFilter);

    mSerialHost = new FTDriver((UsbManager) getSystemService(Context.USB_SERVICE));

    mSerialDevice = new FT311UARTInterface(this, null);

    // Get the local Bluetooth adapter
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // Get a set of currently paired devices
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();

    mBluetoothDevice = null;//from   w  w  w.  j  a  v  a2s.  c o m

    /*   // If there are paired devices, add each one to the ArrayAdapter
       if (pairedDevices.size() > 0) {
          for (BluetoothDevice device : pairedDevices) {
    if (device.getName().equals("PodModeBT"))
       mBluetoothDevice = device;
          }
       }
            
       if (mBluetoothDevice != null) {
          mBTDevice = new BluetoothSerialService(this, mHandler);
          mBTDevice.connect(mBluetoothDevice);
       } */

    // Create the Wifi lock (this does not acquire the lock, this just
    // creates it)
    mWifiLock = ((WifiManager) getSystemService(Context.WIFI_SERVICE))
            .createWifiLock(WifiManager.WIFI_MODE_FULL, "mylock");

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    // Create the retriever and start an asynchronous task that will prepare
    // it.

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    mRetriever = new MusicRetriever(getContentResolver(), getApplicationContext(), true, prefs);

    // mRetriever.switchToMainPlaylist();

    prefs.registerOnSharedPreferenceChangeListener((OnSharedPreferenceChangeListener) this);

    mNowPlaying = prefs.getInt("nowplaying", 0);

    String mBaudrate = prefs.getString("baud_rate", "57600");

    if (mBaudrate.equals("57600"))
        mSerialBaudRate = FTDriver.BAUD57600;
    else if (mBaudrate.equals("38400"))
        mSerialBaudRate = FTDriver.BAUD38400;
    else if (mBaudrate.equals("19200"))
        mSerialBaudRate = FTDriver.BAUD19200;

    (new PrepareMusicRetrieverTask(mRetriever, this)).execute();

    // create the Audio Focus Helper, if the Audio Focus feature is
    // available (SDK 8 or above)
    if (android.os.Build.VERSION.SDK_INT >= 8)
        mAudioFocusHelper = new AudioFocusHelper(getApplicationContext(), this);
    else
        mAudioFocus = AudioFocus.Focused; // no focus feature, so we always
    // "have" audio focus

    boolean wakeLockPreferred = prefs.getBoolean("wakelock", false);

    if (podWakeLock == null && wakeLockPreferred) {
        PowerManager powerMgr = (PowerManager) getSystemService(Context.POWER_SERVICE);
        podWakeLock = powerMgr.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, WAKETAG);
        podWakeLock.acquire();
    }

    PackageManager pxm = getPackageManager();
    Intent mediaIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);

    List<ResolveInfo> mAppsInfo = pxm.queryBroadcastReceivers(mediaIntent, 0);

    mSimpleRemoteApp = prefs.getString("selectapp", null);
    mAdvancedRemoteApp = prefs.getString("selectadvancedapp", PACKAGENAME);

    // Make sure App preferences are still valid and Apps haven't been
    // uninstalled.

    if (mAppsInfo.size() > 0) {

        CharSequence[] entryValues = new CharSequence[mAppsInfo.size()];
        CharSequence[] advEntryValues = new CharSequence[mAppsInfo.size() + 1];

        advEntryValues[0] = PACKAGENAME;

        int i = 0;
        for (ResolveInfo info : mAppsInfo) {
            entryValues[i] = (String) info.activityInfo.packageName;
            advEntryValues[i + 1] = (String) info.activityInfo.packageName;

            i++;
        }

        boolean entryFound = false;

        if (mSimpleRemoteApp != null) {
            for (i = 0; i < entryValues.length; i++) {
                if (mSimpleRemoteApp.equals(entryValues[i])) {
                    entryFound = true;
                }
            }
        }

        if (!entryFound) {
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("selectapp", (String) entryValues[0]);
            editor.commit();
            mSimpleRemoteApp = (String) entryValues[0];
        }

        entryFound = false;

        if (mAdvancedRemoteApp != null) {
            for (i = 0; i < advEntryValues.length; i++) {
                if (mAdvancedRemoteApp.equals(advEntryValues[i])) {
                    entryFound = true;
                }
            }
        }

        if (!entryFound) {
            SharedPreferences.Editor editor = prefs.edit();
            editor.putString("selectadvancedapp", (String) advEntryValues[0]);
            editor.commit();
            mAdvancedRemoteApp = (String) advEntryValues[0];

        }
    } else {
        SharedPreferences.Editor editor = prefs.edit();
        editor.putString("selectadvancedapp", PACKAGENAME);
        editor.commit();
        mAdvancedRemoteApp = PACKAGENAME;
    }

    mAccessoryName = prefs.getString("accessoryName", null);
    mAccessoryMnf = prefs.getString("accessoryMnf", null);
    mAccessoryModel = prefs.getString("accessoryModel", null);

}

From source file:com.notalenthack.blaster.CommandActivity.java

private void setupFilter() {
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Constants.ACTION_REFRESH_STATUS);
    mReceiver = new BroadcastReceiver() {
        @Override//from  w  ww.  j  ava  2  s  .  co  m
        public void onReceive(Context context, Intent intent) {
            // Got intent to clean up
            if (intent.getAction().equals(Constants.ACTION_REFRESH_STATUS)) {
                if (D)
                    Log.d(TAG, "onReceive intent " + intent.toString());
                List<Command> commands = mListAdapter.getCommands();
                // this list should be in the same order as in the ListBox
                int i = 0;
                for (Command cmd : commands) {
                    if (cmd.getDisplayStatus()) {
                        mSerialService.sendStatusCommand(cmd.getCommandStat(), i, false);
                    }
                    i++;
                }
            }
        }
    };
    registerReceiver(mReceiver, filter);
}

From source file:org.droidpres.activity.TransferActivity.java

public void swichWiFi() {
    mWiFiConnectFlag = false;/*  w w w.j  av a  2  s. co m*/

    IntentFilter filter = mFilter;
    WiFiStateReceiver receiver = mWifiStateReceiver;
    if (receiver == null) {
        receiver = new WiFiStateReceiver();
        mWifiStateReceiver = receiver;
        filter = new IntentFilter();
        filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        mFilter = filter;
    }
    this.registerReceiver(receiver, filter);
    getWiFiManager().setWifiEnabled(mWiFiFlag);

    if (mWiFiFlag) {
        new Timer().schedule(new TimerTask() {

            @Override
            public void run() {
                if (!mWiFiConnectFlag) {
                    mWiFiFlag = false;
                    getWiFiManager().setWifiEnabled(mWiFiFlag);
                }
            }
        }, 90000);
    }
}

From source file:com.moez.QKSMS.mmssms.Transaction.java

private void sendMmsMessage(String text, String[] addresses, Bitmap[] image, String[] imageNames, byte[] media,
        String mimeType, String subject) {
    // merge the string[] of addresses into a single string so they can be inserted into the database easier
    String address = "";

    for (int i = 0; i < addresses.length; i++) {
        address += addresses[i] + " ";
    }//from  w ww  .  ja  v a2s  .  c  o  m

    address = address.trim();

    // create the parts to send
    ArrayList<MMSPart> data = new ArrayList<>();

    for (int i = 0; i < image.length; i++) {
        // turn bitmap into byte array to be stored
        byte[] imageBytes = Message.bitmapToByteArray(image[i]);

        MMSPart part = new MMSPart();
        part.MimeType = "image/jpeg";
        part.Name = (imageNames != null) ? imageNames[i] : ("image" + i);
        part.Data = imageBytes;
        data.add(part);
    }

    // add any extra media according to their mimeType set in the message
    //      eg. videos, audio, contact cards, location maybe?
    if (media.length > 0 && mimeType != null) {
        MMSPart part = new MMSPart();
        part.MimeType = mimeType;
        part.Name = mimeType.split("/")[0];
        part.Data = media;
        data.add(part);
    }

    if (!text.equals("")) {
        // add text to the end of the part and send
        MMSPart part = new MMSPart();
        part.Name = "text";
        part.MimeType = "text/plain";
        part.Data = text.getBytes();
        data.add(part);
    }

    MessageInfo info;

    try {
        info = getBytes(context, saveMessage, address.split(" "), data.toArray(new MMSPart[data.size()]),
                subject);
    } catch (MmsException e) {
        Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
        return;
    }

    try {
        MmsMessageSender sender = new MmsMessageSender(context, info.location, info.bytes.length);
        sender.sendMessage(info.token);

        IntentFilter filter = new IntentFilter();
        filter.addAction(ProgressCallbackEntity.PROGRESS_STATUS_ACTION);
        BroadcastReceiver receiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                int progress = intent.getIntExtra("progress", -3);
                if (LOCAL_LOGV)
                    Log.v(TAG, "progress: " + progress);

                // send progress broadcast to update ui if desired...
                Intent progressIntent = new Intent(MMS_PROGRESS);
                progressIntent.putExtra("progress", progress);
                context.sendBroadcast(progressIntent);

                if (progress == ProgressCallbackEntity.PROGRESS_COMPLETE) {
                    context.sendBroadcast(new Intent(REFRESH));

                    try {
                        context.unregisterReceiver(this);
                    } catch (Exception e) {
                        // TODO fix me
                        // receiver is not registered force close error... hmm.
                    }
                } else if (progress == ProgressCallbackEntity.PROGRESS_ABORT) {
                    // This seems to get called only after the progress has reached 100 and then something else goes wrong, so here we will try and send again and see if it works
                    if (LOCAL_LOGV)
                        Log.v(TAG, "sending aborted for some reason...");
                }
            }

        };

        context.registerReceiver(receiver, filter);
    } catch (Throwable e) {
        Log.e(TAG, "exception thrown", e);
        // insert the pdu into the database and return the bytes to send
        if (settings.getWifiMmsFix()) {
            sendMMS(info.bytes);
        } else {
            sendMMSWiFi(info.bytes);
        }
    }
}

From source file:com.samsung.soundscape.util.ConnectivityManager.java

/**
 * Register network change listeners.//from w  w  w. j  ava2  s  .  c o m
 */
private void registerWiFiStateListener() {
    IntentFilter mWiFiStateFilter = new IntentFilter();
    mWiFiStateFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    mWiFiStateFilter.addAction(android.net.ConnectivityManager.CONNECTIVITY_ACTION);
    App.getInstance().registerReceiver(mWifiStateChangedReceiver, mWiFiStateFilter);
}

From source file:com.tealeaf.TeaLeaf.java

private void registerScreenOffReceiver() {
    if (screenOffReciever == null) {
        makeScreenOffReceiver();//w w  w.  j a  va2 s  .co  m
    }
    IntentFilter filter = new IntentFilter();

    filter.addAction("android.intent.action.SCREEN_OFF");
    registerReceiver(screenOffReciever, filter);

}

From source file:com.dwdesign.tweetings.fragment.BaseStatusesListFragment.java

@Override
public void onStart() {
    super.onStart();
    mTickerStopped = false;//  w  w  w .  j  a  v  a2 s .  c  o m
    mHandler = new Handler();

    mTicker = new Runnable() {

        @Override
        public void run() {
            if (mTickerStopped)
                return;
            if (mListView != null && !mBusy) {
                getListAdapter().notifyDataSetChanged();
            }
            final long now = SystemClock.uptimeMillis();
            final long next = now + TICKER_DURATION - now % TICKER_DURATION;
            mHandler.postAtTime(mTicker, next);
        }
    };
    mTicker.run();

    final IntentFilter filter = new IntentFilter();
    filter.addAction(BROADCAST_MULTI_SELECT_STATE_CHANGED);
    filter.addAction(BROADCAST_MULTI_SELECT_ITEM_CHANGED);
    registerReceiver(mStateReceiver, filter);

    onPostStart();
}