Example usage for android.content IntentFilter setPriority

List of usage examples for android.content IntentFilter setPriority

Introduction

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

Prototype

public final void setPriority(int priority) 

Source Link

Document

Modify priority of this filter.

Usage

From source file:org.odk.collect.android.activities.InstanceUploaderListActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (instanceSyncTask != null) {
        instanceSyncTask.setDiskSyncListener(this);
        if (instanceSyncTask.getStatus() == AsyncTask.Status.FINISHED) {
            syncComplete(instanceSyncTask.getStatusMessage());
        }/*  ww w. ja va2s.co m*/

    }

    IntentFilter filter = new IntentFilter(SmsNotificationReceiver.SMS_NOTIFICATION_ACTION);
    // The default priority is 0. Positive values will be before
    // the default, lower values will be after it.
    filter.setPriority(1);

    registerReceiver(smsForegroundReceiver, filter);
    setupUploadButtons();
}

From source file:com.keithandthegirl.ui.activity.GuestsDashboardFragment.java

@Override
public void onResume() {
    Log.v(TAG, "onResume : enter");
    super.onResume();

    mDownloadServiceHelper = DownloadServiceHelper.getInstance(getActivity());

    IntentFilter downloadFilter = new IntentFilter(DownloadServiceHelper.DOWNLOAD_RESULT);
    downloadFilter.setPriority(IntentFilter.SYSTEM_LOW_PRIORITY);
    downloadReceiver = new DownloadReceiver();
    getActivity().registerReceiver(downloadReceiver, downloadFilter);

    if (null != mainApplication.getGuest()) {
        Log.v(TAG, "onResume : already downloaded guest list");

        if (null != mainApplication.getGuest().getGuests()
                && !mainApplication.getGuest().getGuests().isEmpty()) {
            Log.v(TAG, "onResume : guestList has entries");

            guestList = mainApplication.getGuest().getGuests();
        }/*from ww  w  . j a  v  a2 s. c o  m*/
    }

    if (guestList.isEmpty()) {
        Log.v(TAG, "onResume : guestList is empty");

        File root;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
            root = getActivity().getExternalCacheDir();
        } else {
            root = Environment.getExternalStorageDirectory();
        }

        File dataDir = new File(root, DATA_DIR);
        dataDir.mkdirs();

        File f = new File(dataDir, "Guests.xml");
        if (f.exists()) {

            Serializer serializer = new Persister();

            try {
                Guests guests = serializer.read(Guests.class, f);
                setDownloadedGuests(guests);
            } catch (Exception e) {
                Log.w(TAG, "onResume : error reading guests file");
            }
        } else {
            mainApplication.setGuestSort(MainApplication.Sort.MOST_RECENT);
            new DownloadGuestTask().execute(MainApplication.Sort.MOST_RECENT);
        }

    } else {
        setupAdapter();
    }

    Log.v(TAG, "onResume : exit");
}

From source file:com.easemob.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();//  w  w  w  . j a v  a 2  s  .c  om
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    chatHistoryFragment = new ChatHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
            .add(R.id.fragment_container, contactListFragment).hide(contactListFragment)
            .show(chatHistoryFragment).commit();

    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:com.runye.express.chat.activity.ChatMainActivity.java

private void test() {
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    chatHistoryFragment = new ChatHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
    // fragment/* w  w w  .j  av  a2  s  .co  m*/
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
            .add(R.id.fragment_container, contactListFragment).hide(contactListFragment)
            .show(chatHistoryFragment).commit();
    //
    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:org.durka.hallmonitor.CoreStateManager.java

public void registerCoreReceiver() {
    if (mCoreReceiver == null) {
        /*/*from  w ww.j  a va 2 s. c o m*/
         * HEADSET_PLUG, SCREEN_ON and SCREEN_OFF only available through
         * registerReceiver function
         */
        mCoreReceiver = new CoreReceiver();
        IntentFilter intfil = new IntentFilter();
        intfil.setPriority(990);
        intfil.addAction(Intent.ACTION_HEADSET_PLUG);
        intfil.addAction(Intent.ACTION_SCREEN_ON);
        intfil.addAction(Intent.ACTION_SCREEN_OFF);

        if (preference_all.getBoolean("pref_internalservice", false)) {
            IntentFilter mIntentFilter = new IntentFilter();
            mIntentFilter.addAction(getActionCover());
            LocalBroadcastManager.getInstance(mAppContext).registerReceiver(mCoreReceiver, mIntentFilter);
        } else {
            intfil.addAction(CoreReceiver.ACTION_LID_STATE_CHANGED);
        }

        mAppContext.registerReceiver(mCoreReceiver, intfil);
    }
}

From source file:com.zhixu.icu.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    initView();//ww w . j a v a 2s  . c o  m

    //?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();

    FragmentTransaction trx = getSupportFragmentManager().beginTransaction();

    trx.add(R.id.main_scroll, chatHistoryFragment);
    trx.add(R.id.main_scroll, contactListFragment);
    trx.add(R.id.main_scroll, settingFragment);
    trx.show(chatHistoryFragment);
    trx.show(contactListFragment);
    trx.show(settingFragment).commit();

    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);

    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ?BroadcastReceiver
    //      IntentFilter offlineMessageIntentFilter = new IntentFilter(EMChatManager.getInstance()
    //            .getOfflineMessageBroadcastAction());
    //      registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:app.view.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity_layout);
    initView();/* ww w . j a v a2s  . c om*/
    inviteMessageDao = new InviteMessageDao(this);
    userDao = new UserDao(this);

    //fragments
    playListFragment = new PlayListFragment();
    circleFragment = new CircleFragment();
    chatHistoryFragment = new ChatAllHistoryFragment();//?
    contactListFragment = new ContactListFragment();//
    fragments = new Fragment[] { playListFragment, circleFragment, chatHistoryFragment, contactListFragment };

    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, playListFragment)
            .add(R.id.fragment_container, circleFragment).hide(circleFragment).show(playListFragment).commit();

    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ?BroadcastReceiver
    IntentFilter offlineMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getOfflineMessageBroadcastAction());
    registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:niltor.net.chatuidemo.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();//from   w  ww  .  j  ava 2s . c  o m
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    //fragment???
    //      chatHistoryFragment = new ChatHistoryFragment();
    //?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
            .add(R.id.fragment_container, contactListFragment).hide(contactListFragment)
            .show(chatHistoryFragment).commit();

    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ?BroadcastReceiver
    IntentFilter offlineMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getOfflineMessageBroadcastAction());
    registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:com.lnpdit.chatuidemo.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();/*from w ww .  j  ava2s.  c o  m*/
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    //fragment???
    //      chatHistoryFragment = new ChatHistoryFragment();
    //?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    indexFragment = new IndexFragment();
    fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment, indexFragment };
    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, indexFragment)
            .add(R.id.fragment_container, chatHistoryFragment).show(indexFragment).hide(contactListFragment)
            .hide(chatHistoryFragment).commit();

    // ?BroadcastReceiver
    msgReceiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    intentFilter.setPriority(3);
    registerReceiver(msgReceiver, intentFilter);

    // ack?BroadcastReceiver
    IntentFilter ackMessageIntentFilter = new IntentFilter(
            EMChatManager.getInstance().getAckMessageBroadcastAction());
    ackMessageIntentFilter.setPriority(3);
    registerReceiver(ackMessageReceiver, ackMessageIntentFilter);

    // ?BroadcastReceiver
    //      IntentFilter offlineMessageIntentFilter = new IntentFilter(EMChatManager.getInstance()
    //            .getOfflineMessageBroadcastAction());
    //      registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter);

    // setContactListener???
    EMContactManager.getInstance().setContactListener(new MyContactListener());
    // ??listener
    EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
    // ?listener
    EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
    // sdkUI ??receiverlistener, ??broadcast
    EMChat.getInstance().setAppInited();
}

From source file:com.keithandthegirl.ui.activity.EpisodesFragment.java

@TargetApi(11)
@Override//from  www  . j av  a  2 s. c  o  m
public void onResume() {
    Log.v(TAG, "onResume : enter");
    super.onResume();

    bindToService();

    mEpisodeServiceHelper = EpisodeServiceHelper.getInstance(getActivity());
    mDownloadServiceHelper = DownloadServiceHelper.getInstance(getActivity());

    IntentFilter episodeFilter = new IntentFilter(EpisodeServiceHelper.EPISODE_RESULT);
    episodeFilter.setPriority(IntentFilter.SYSTEM_LOW_PRIORITY);
    episodesReceiver = new EpisodesReceiver();
    getActivity().registerReceiver(episodesReceiver, episodeFilter);

    IntentFilter downloadFilter = new IntentFilter(DownloadServiceHelper.DOWNLOAD_RESULT);
    downloadReceiver = new DownloadReceiver();
    getActivity().registerReceiver(downloadReceiver, downloadFilter);

    Cursor episodeCursor = getActivity().getContentResolver().query(EpisodeConstants.CONTENT_URI,
            new String[] { EpisodeConstants._ID }, null, null, null);
    if (episodeCursor.getCount() == 0) {
        loadData();
    }
    episodeCursor.close();

    if (mBound) {
        Log.v(TAG, "onResume : service is bound");

        mMediaPlayer = mService.getMediaPlayer();
        mSelectedStream = mMediaPlayer.getStreamStation();

        adapter.notifyDataSetChanged();
    }

    Log.v(TAG, "onResume : exit");
}