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:com.haomee.chat.activity.ChatActivity.java

private void setUpView() {
    // position = getIntent().getIntExtra("position", -1);
    clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    manager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "demo");
    init_from_data();/*from  w  ww .  j  ava 2s. co m*/

    // conversation =
    // EMChatManager.getInstance().getConversation(toChatUsername,false);
    conversation = EMChatManager.getInstance().getConversation(toChatUsername);
    // ?0
    conversation.resetUnsetMsgCount();
    adapter = new MessageAdapter(this, toChatUsername, chatType, uId);
    // ?
    listView.setAdapter(adapter);
    listView.setOnScrollListener(new ListScrollListener());
    int count = listView.getCount();
    if (count > 0) {
        listView.setSelection(count - 1);
    }

    listView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            hideKeyboard();
            hideBottom();
            return false;
        }
    });
    // ?
    receiver = new NewMessageBroadcastReceiver();
    IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
    // Mainacitivity,??chat??????
    intentFilter.setPriority(5);
    registerReceiver(receiver, intentFilter);

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

    String forward_msg_id = getIntent().getStringExtra("forward_msg_id");
    if (forward_msg_id != null) {
        // ?????
        forwardMessage(forward_msg_id);
    }

}

From source file:edu.cmu.cylab.starslinger.view.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Safeslinger);
    super.onCreate(savedInstanceState);
    Crashlytics.start(this);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);// ww  w .ja va  2 s .  co m
    setContentView(mViewPager);

    final ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setTitle(R.string.app_name);
    if (!SSUtil.isGoogleAccountPresent(getApplicationContext())) {
        bar.setSubtitle(String.format("(%s)", getString(R.string.label_DeviceInSendOnlyMode)));
    }

    mTabsAdapter = new TabsAdapter(this, bar, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.menu_TagListMessages), MessagesFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.menu_TagComposeMessage), ComposeFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.menu_TagExchange), SlingerFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.menu_Introduction), IntroductionFragment.class, null);

    if (savedInstanceState != null) {
        setTab(Tabs.values()[savedInstanceState.getInt(extra.RECOVERY_TAB)]);
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // prepare for push registration...
    registerReceiver(mPushRegReceiver, new IntentFilter(C2DMReceiver.PUSH_REGISTERED));
    IntentFilter intentFilter = new IntentFilter(SafeSlingerConfig.Intent.ACTION_MESSAGEINCOMING);
    intentFilter.setPriority(2);
    registerReceiver(mMsgIncomingReceiver, intentFilter);
    registerReceiver(mMsgOutgoingReceiver, new IntentFilter(SafeSlingerConfig.Intent.ACTION_MESSAGEOUTGOING));

    if (savedInstanceState == null) {
        // init app launch once all time

        if (loadCurrentPassPhrase()) {
            processIntent(getIntent());
        }

        boolean dateChanged = SSUtil.isDayChanged(SafeSlingerPrefs.getContactDBLastScan());
        if (dateChanged) {
            SafeSlingerPrefs.setThisVersionOpened();
            BackgroundSyncUpdatesTask backgroundSyncUpdates = new BackgroundSyncUpdatesTask();
            backgroundSyncUpdates.execute(new String());
        }

        // init on reload once all time
        if (!isSetupCheckComplete()) {
            return;
        }
    }
}

From source file:com.tct.mail.ui.AbstractActivityController.java

@Override
public void onStart() {
    mSafeToModifyFragments = true;// ww w . jav a 2s  .c  o m

    NotificationActionUtils.registerUndoNotificationObserver(mUndoNotificationObserver);

    if (mViewMode.getMode() != ViewMode.UNKNOWN) {
        Analytics.getInstance().sendView("MainActivity" + mViewMode.toString());
    }
    IntentFilter filter = new IntentFilter(ComposeActivity.DRAFT_SAVED_ACTION);
    filter.setPriority(DRAFT_SAVE_PRIORITY);
    mActivity.registerReceiver(mDraftReceiver, filter); //TS: zheng.zou 2015-03-18 EMAIL FEATURE_996919 ADD
}

From source file:org.restcomm.app.qoslib.Services.Intents.IntentHandler.java

public IntentFilter declareIntentFilters() {
    IntentFilter intentFilter = new IntentFilter(IntentHandler.UPDATE_ACTION);
    intentFilter.addAction(IntentHandler.START_TRACKING_ACTION);
    intentFilter.addAction(IntentHandler.TRACK_REMOTE);
    intentFilter.addAction(IntentHandler.STOP_TRACKING_ACTION);
    intentFilter.addAction(IntentHandler.SPEED_TEST);
    intentFilter.addAction(IntentHandler.RUN_WEBSOCKET);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_START_UI);

    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_LOCATION_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_CELL_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_GPS_STATUS_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_SIGNAL_STRENGTH_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_EVENT_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_NEIGHBOR_UPDATE);
    intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_NETWORK_UPDATE);
    //intentFilter.addAction(CommonIntentBundleKeysOld.ACTION_RX_TX);

    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_RESULT);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_ERROR);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_COMPLETE);
    intentFilter.addAction(IntentHandler.ACTION_SPEEDTEST_CANCELLED);

    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_RESULT);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_ERROR);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_COMPLETE);
    intentFilter.addAction(IntentHandler.ACTION_WEBTEST_CANCELLED);

    //do not add filter if sms test permissions aren't all allowed
    if (PreferenceKeys.getSMSPermissionsAllowed(owner, true))
        intentFilter.addAction(IntentHandler.SMS_TEST);

    intentFilter.addAction(IntentHandler.SMS_DELIVERED);
    intentFilter.addAction(IntentHandler.LATENCY_TEST);
    intentFilter.addAction(IntentHandler.ACTION_STOP_SPEEDTEST);
    intentFilter.addAction(IntentHandler.RESTART_MMC_SERVICE);
    intentFilter.addAction(IntentHandler.COLDRESET_ACTION);
    intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
    intentFilter.addAction(Intent.ACTION_POWER_CONNECTED);
    intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    intentFilter.addAction(Intent.ACTION_SCREEN_ON);
    intentFilter.addAction(IntentHandler.COMMAND);
    intentFilter.addAction(IntentHandler.SURVEY);
    //intentFilter.addAction(Intent.ACTION_VIEW);
    //intentFilter.addAction("android.intent.PHONE_STATE");
    intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_TRACKING_5MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_TRACKING_1MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_3HOUR);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_15MINUTE);
    intentFilter.addAction(IntentHandler.ACTION_ALARM_SCANAPPS);
    intentFilter.addAction(IntentHandler.EMAIL_CSV);
    intentFilter.addAction(IntentHandler.GPS_STATE_OFF);
    intentFilter.addAction(IntentHandler.GPS_STATE_ON);
    intentFilter.addAction(IntentHandler.PHONE_CALL_CONNECT);
    intentFilter.addAction(IntentHandler.PHONE_CALL_DISCONNECT);
    intentFilter.addAction(IntentHandler.HANDOFF);
    //intentFilter.addAction(IntentHandler.SMS_SENT);
    intentFilter.addAction(IntentHandler.SMS_RECEIVED);
    intentFilter.addAction(Intent.ACTION_SEND);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_START);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_END);
    intentFilter.addAction(IntentHandler.MANUAL_PLOTTING_CANCEL);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_START);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_END);
    intentFilter.addAction(IntentHandler.MANUAL_TRANSIT_CANCEL);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
    intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);

    intentFilter.addAction(Intent.ACTION_HEADSET_PLUG);
    intentFilter.addAction(IntentHandler.ROAMING_ON);
    intentFilter.addAction(IntentHandler.ROAMING_OFF);

    intentFilter.addAction(IntentHandler.VIEWING_SIGNAL);
    intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    intentFilter.addAction("android.intent.action.PRECISE_CALL_STATE");
    intentFilter.addAction("android.intent.action.PRECISE_DATA_CONNECTION_STATE_CHANGED");
    intentFilter.addAction("android.intent.action.PHONE_STATE");
    intentFilter.addAction("android.intent.action.NEW_OUTGOING_CALL");

    intentFilter.addAction("android.intent.action.DATA_CONNECTION_CONNECTED_TO_PROVISIONING_APN");
    intentFilter.addAction("android.intent.action.ANY_DATA_STATE");
    intentFilter.addAction("android.intent.action.ACTION_DATA_CONNECTION_FAILED");

    intentFilter.addAction(CommonIntentActionsOld.ACTION_BLUETOOTH_ENDDOWNLOAD);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_START_VOICETEST);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_STOP_VOICETEST);
    intentFilter.addAction(CommonIntentActionsOld.ACTION_TEST_VQ_DEVICE);

    intentFilter.addAction(IntentHandler.ACTIVE_TEST);
    intentFilter.addAction(IntentHandler.ACTION_STOP_VIDEOTEST);
    intentFilter.addAction(IntentHandler.GCM_MESSAGE);

    intentFilter.addAction("org.restcomm.android.CONNECT_FAILED");
    intentFilter.addAction("org.restcomm.android.CALL_STATE");
    intentFilter.addAction("org.restcomm.android.DISCONNECT_ERROR");

    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_DISCONNECT);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_CONNECT);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_NEIGHBORS);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_SERVICEMODE);
    intentFilter.addAction(IntentHandler.ACTION_RADIOLOG_SERVICEMENU);
    intentFilter.addAction(IntentHandler.ACTION_MMCSYS_VERSION);

    //intentFilter.addAction(Intent.ACTION_APP_ERROR);
    int raisePriority = owner.getPackageManager().checkPermission("android.permission.RAISED_THREAD_PRIORITY",
            owner.getPackageName());//from   w  w  w .j av  a2s  . c  o m
    // With permission to raise priority for SMS messages
    if (raisePriority == 0)
        intentFilter.setPriority(9999999);

    return intentFilter;
}