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(Parcel source) 

Source Link

Usage

From source file:net.sf.diningout.app.ui.FriendsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mReceiver = new Receiver();
    IntentFilter filter = new IntentFilter(ACTION_CONTACTS_SYNCING);
    filter.addAction(ACTION_CONTACTS_SYNCED);
    LocalBroadcastManager.getInstance(a).registerReceiver(mReceiver, filter);
    a.getActionBar().setIcon(R.drawable.logo); // expanded SearchView uses icon
    setHasOptionsMenu(true);//from  w ww.j  a va2 s .  c o  m
}

From source file:com.pandoroid.PandoraRadioService.java

@Override
public void onCreate() {
    m_paused = false;//  w w w .j a  v a2  s  .c o  m
    m_pandora_remote = new PandoraRadio();
    image_downloader = new ImageDownloader();
    m_stations = new ArrayList<Station>();

    connectivity_manager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    m_prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    // Register the listener with the telephony manager
    telephonyManager.listen(new PhoneStateListener() {
        boolean pausedForRing = false;

        @Override
        public void onCallStateChanged(int state, String incomingNumber) {
            switch (state) {

            case TelephonyManager.CALL_STATE_IDLE:
                if (pausedForRing && m_song_playback != null) {
                    if (m_prefs.getBoolean("behave_resumeOnHangup", true)) {
                        if (m_song_playback != null && !m_paused) {
                            m_song_playback.play();
                        }
                    }
                }

                pausedForRing = false;
                break;

            case TelephonyManager.CALL_STATE_OFFHOOK:
            case TelephonyManager.CALL_STATE_RINGING:
                if (m_song_playback != null) {
                    m_song_playback.pause();
                }

                pausedForRing = true;
                break;
            }
        }
    }, PhoneStateListener.LISTEN_CALL_STATE);

    m_music_intent_receiver = new MusicIntentReceiver();
    this.registerReceiver(m_music_intent_receiver, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY));
}

From source file:com.cellbots.local.EyesView.java

public EyesView(CellDroidActivity ct, String url, boolean torch) {
    Log.e("remote eyes", "started " + url);
    mParent = ct;/* w  ww .  j a v  a2 s  . co m*/
    putUrl = url;

    PowerManager pm = (PowerManager) ct.getSystemService(Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP,
            "Cellbot Eyes");
    mWakeLock.acquire();

    out = new ByteArrayOutputStream();

    if (putUrl != null) {
        isLocalUrl = putUrl.contains("127.0.0.1") || putUrl.contains("localhost");
        server = putUrl.replace("http://", "");
        server = server.substring(0, server.indexOf("/"));
        mTorchMode = torch;
        resetConnection();
        mHttpState = new HttpState();
    }

    ct.setContentView(R.layout.eyes_main);
    mPreview = (SurfaceView) ct.findViewById(R.id.eyes_preview);
    mHolder = mPreview.getHolder();
    mHolder.addCallback(this);
    mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    mPreview.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            setTorchMode(!mTorchMode);
        }
    });

    mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            boolean useTorch = intent.getBooleanExtra("TORCH", false);
            boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false);
            setTorchMode(useTorch);
            setTakePicture(shouldTakePicture);
        }
    };

    ct.registerReceiver(mReceiver, new IntentFilter(EyesView.EYES_COMMAND));

    mFrame = (FrameLayout) ct.findViewById(R.id.eyes_frame);
    mImageView = new ImageView(ct);
    mImageView.setScaleType(ScaleType.FIT_CENTER);
    mImageView.setBackgroundColor(Color.BLACK);

    setPersona(PERSONA_READY);

    mFrame.addView(mImageView);
}

From source file:com.brodev.socialapp.fragment.EventDetailFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getActivity().registerReceiver(mHandleMessageReceiver, new IntentFilter(Config.DISPLAY_UPDATE_RSVP));
    actualListView = mPullRefreshListView.getRefreshableView();

    try {//  www  .  ja  va  2s .  com
        new EventTask().execute(eventId);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.huzefagadi.brownbear.fragments.ImagePagerFragment.java

@Override
public void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    IntentFilter intentFilterEdit = new IntentFilter("com.huzefagadi.brownbear.NOTIFY");
    context.registerReceiver(receiver, intentFilterEdit);
    if (timer != null) {
        slideshow();/*from   ww  w . j a  v  a 2  s  . co  m*/
    }

}

From source file:com.hedgehog.smdb.ActionBarControlScrollViewActivity.java

private void repeat() {
    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override/*from   w w  w . j  a  va2s.  c  o  m*/
        public void onReceive(Context context, Intent intent) {
            showNotification();
        }
    };

    this.registerReceiver(receiver, new IntentFilter("TecxiDriverCheckingForConfirmedBids"));
    PendingIntent pintent = PendingIntent.getBroadcast(this, 0,
            new Intent("TecxiDriverCheckingForConfirmedBids"), 0);
    AlarmManager manager = (AlarmManager) (this.getSystemService(Context.ALARM_SERVICE));
    manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 0, 1000 * 60 * 30, pintent);
}

From source file:net.primeranks.fs_viewer.fs_replay.EntryPointActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.entry_point);

    ListView listView = getListView();
    listView.setOnItemClickListener(this);

    // Add a back to top button on the bottom       - Create the item
    backToTop_footer = (Button) getLayoutInflater().inflate(R.layout.user_footer, null);
    backToTop_footer.setCompoundDrawablesWithIntrinsicBounds(
            getResources().getDrawable(android.R.drawable.ic_menu_upload), null, null, null);
    backToTop_footer.setVisibility(View.INVISIBLE); // While empty do not show it
    headerUser = getLayoutInflater().inflate(R.layout.user_header, null);
    listView.addFooterView(backToTop_footer, null, true); // Add it to the bottom
    listView.addHeaderView(headerUser, null, false);

    userList = new ArrayList<User>(); // Start with an empty one
    this.userAdapter = new UserAdapter(this, userList);
    listView.setAdapter(this.userAdapter);
    listView.setItemsCanFocus(false);/*from  ww  w.j a  v a  2  s.  c o  m*/

    connectionReceiver = new ConnectionChangedBroadcastReceiver();
    registerReceiver(connectionReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}

From source file:de.nico.asura.Main.java

@Override
protected void onResume() {
    super.onResume();
    IntentFilter intentFilter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    registerReceiver(downloadReceiver, intentFilter);
}

From source file:com.csipsimple.service.DownloadLibService.java

@Override
public void onCreate() {
    Log.d(THIS_FILE, "Download Lib Service started");

    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    // Lock wifi if possible to ensure download will be done
    wifiLock = ((WifiManager) getSystemService(WIFI_SERVICE))
            .createWifiLock("com.csipsimple.service.DownloadLibService");
    connectivityManager = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE);
    connectionChangeReceiver = new ConnectionChangeReceiver();
    registerReceiver(connectionChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
    if (activeNetwork != null) {
        NetworkInfo.State state = activeNetwork.getState();
        connected = (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.SUSPENDED);
    } else {/*from   w  w  w  .  j a v a 2s  .c  o m*/
        connected = false;
    }

}

From source file:com.easemob.chatui.DemoHXSDKHelper.java

/**
 * ?//from  w  ww.  ja  va 2 s  .c  o m
 * ?UI???UI???????
 * activityList.size() <= 0 ????????Activity Stack
 */
protected void initEventListener() {
    eventListener = new EMEventListener() {
        private BroadcastReceiver broadCastReceiver = null;

        @Override
        public void onEvent(EMNotifierEvent event) {
            EMMessage message = null;
            if (event.getData() instanceof EMMessage) {
                message = (EMMessage) event.getData();
                EMLog.d(TAG, "receive the event : " + event.getEvent() + ",id : " + message.getMsgId());
            }

            switch (event.getEvent()) {
            case EventNewMessage:
                //????UI,????
                if (activityList.size() <= 0) {
                    HXSDKHelper.getInstance().getNotifier().onNewMsg(message);
                }
                break;
            case EventOfflineMessage:
                if (activityList.size() <= 0) {
                    EMLog.d(TAG, "received offline messages");
                    List<EMMessage> messages = (List<EMMessage>) event.getData();
                    HXSDKHelper.getInstance().getNotifier().onNewMesg(messages);
                }
                break;

            case EventNewCMDMessage: {

                EMLog.d(TAG, "??");
                //??body
                CmdMessageBody cmdMsgBody = (CmdMessageBody) message.getBody();
                final String action = cmdMsgBody.action;//?action

                //? ?
                //message.getStringAttribute("");
                EMLog.d(TAG, String.format("??action:%s,message:%s", action, message.toString()));
                final String str = appContext.getString(R.string.receive_the_passthrough);

                final String CMD_TOAST_BROADCAST = "easemob.demo.cmd.toast";
                IntentFilter cmdFilter = new IntentFilter(CMD_TOAST_BROADCAST);

                if (broadCastReceiver == null) {
                    broadCastReceiver = new BroadcastReceiver() {

                        @Override
                        public void onReceive(Context context, Intent intent) {
                            // TODO Auto-generated method stub
                            Toast.makeText(appContext, intent.getStringExtra("cmd_value"), Toast.LENGTH_SHORT)
                                    .show();
                        }
                    };

                    //
                    appContext.registerReceiver(broadCastReceiver, cmdFilter);
                }

                Intent broadcastIntent = new Intent(CMD_TOAST_BROADCAST);
                broadcastIntent.putExtra("cmd_value", str + action);
                appContext.sendBroadcast(broadcastIntent, null);

                break;
            }
            case EventDeliveryAck:
                message.setDelivered(true);
                break;
            case EventReadAck:
                message.setAcked(true);
                break;
            // add other events in case you are interested in
            default:
                break;
            }

        }
    };

    EMChatManager.getInstance().registerEventListener(eventListener);

    EMChatManager.getInstance().addChatRoomChangeListener(new EMChatRoomChangeListener() {
        private final static String ROOM_CHANGE_BROADCAST = "easemob.demo.chatroom.changeevent.toast";
        private final IntentFilter filter = new IntentFilter(ROOM_CHANGE_BROADCAST);
        private boolean registered = false;

        private void showToast(String value) {
            if (!registered) {
                //
                appContext.registerReceiver(new BroadcastReceiver() {

                    @Override
                    public void onReceive(Context context, Intent intent) {
                        Toast.makeText(appContext, intent.getStringExtra("value"), Toast.LENGTH_SHORT).show();
                    }

                }, filter);

                registered = true;
            }

            Intent broadcastIntent = new Intent(ROOM_CHANGE_BROADCAST);
            broadcastIntent.putExtra("value", value);
            appContext.sendBroadcast(broadcastIntent, null);
        }

        @Override
        public void onChatRoomDestroyed(String roomId, String roomName) {
            showToast(" room : " + roomId + " with room name : " + roomName + " was destroyed");
            Log.i("info", "onChatRoomDestroyed=" + roomName);
        }

        @Override
        public void onMemberJoined(String roomId, String participant) {
            showToast("member : " + participant + " join the room : " + roomId);
            Log.i("info", "onmemberjoined=" + participant);

        }

        @Override
        public void onMemberExited(String roomId, String roomName, String participant) {
            showToast("member : " + participant + " leave the room : " + roomId + " room name : " + roomName);
            Log.i("info", "onMemberExited=" + participant);

        }

        @Override
        public void onMemberKicked(String roomId, String roomName, String participant) {
            showToast("member : " + participant + " was kicked from the room : " + roomId + " room name : "
                    + roomName);
            Log.i("info", "onMemberKicked=" + participant);

        }

    });
}