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:com.ccxt.whl.activity.MainActivity_0903.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //?//from w  w w  .j av a 2 s .co  m
    DemoApplication.currentUserNick = DemoApplication.getInstance().getUsernNickName();
    initView();
    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);

    zainaFrament = new ZainaFragment();
    gushiFrament = new Zaina_gushi_Fragment();
    //fragment???
    //      chatHistoryFragment = new ChatHistoryFragment();
    //?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    //fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
    fragments = new Fragment[] { zainaFrament, gushiFrament, chatHistoryFragment, contactListFragment,
            settingFragment };

    // fragment
    /*   getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
    .add(R.id.fragment_container, contactListFragment).hide(contactListFragment).show(chatHistoryFragment)
    .commit();*/
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, zainaFrament)
            .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();
    /********/
    loadcontact();
    //showFloatingButton();
}

From source file:net.oschina.app.ui.MainActivity.java

@Override
public void initView() {
    mDoubleClickExit = new DoubleClickExitHelper(this);
    //        @InjectView(android.R.id.tabhost)
    //        public MyFragmentTabHost mTabHost;

    mAddBt = findViewById(R.id.quick_option_iv);

    mTabHost = (MyFragmentTabHost) findViewById(android.R.id.tabhost);
    //TODO/*from   w w w  .j  a  va2s  . c  o  m*/
    //        mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
    //                .findFragmentById(R.id.navigation_drawer);
    mTitle = getTitle();

    // Set up the drawer.
    //TODO
    //        mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
    //                (DrawerLayout) findViewById(R.id.drawer_layout));

    mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
    if (android.os.Build.VERSION.SDK_INT > 10) {
        mTabHost.getTabWidget().setShowDividers(0);
    }

    initTabs();

    // ?
    mAddBt.setOnClickListener(this);
    mAddBt.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            startActivity(new Intent(MainActivity.this, NetSetupActivity.class));
            return true;
        }
    });

    mTabHost.setCurrentTab(0);
    mTabHost.setOnTabChangedListener(this);

    IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_NOTICE);
    filter.addAction(Constants.INTENT_ACTION_LOGOUT);
    registerReceiver(mReceiver, filter);
    NoticeUtils.bindToService(this);

    if (AppContext.isFristStart()) {
        //            mNavigationDrawerFragment.openDrawerMenu();
        DataCleanManager.cleanInternalCache(AppContext.getInstance());
        AppContext.setFristStart(false);
    }

    //        checkUpdate();
}

From source file:com.nagopy.android.xposed.utilities.ModBrightness.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@XMinSdkVersion(Build.VERSION_CODES.JELLY_BEAN_MR1)
@HandleInitPackageResources(targetPackage = XConst.PKG_SYSTEM_UI, summary = "??")
public static void brightnessDebugger(final String modulePath, final InitPackageResourcesParam resparam,
        final ModBrightnessSettingsGen settings) throws Throwable {
    if (!settings.brightnessDebugger) {
        return;/*  ww w  .  ja  v a 2  s .c o m*/
    }

    resparam.res.hookLayout(XConst.PKG_SYSTEM_UI, "layout", "super_status_bar", new XC_LayoutInflated() {
        @Override
        public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
            LinearLayout parent = (LinearLayout) liparam.view
                    .findViewById(liparam.res.getIdentifier("system_icon_area", "id", XConst.PKG_SYSTEM_UI));

            // ?
            TextView luxTextView = new TextView(parent.getContext());
            luxTextView.setTextSize(8);
            luxTextView.setSingleLine(false);
            luxTextView.setTextColor(Color.WHITE);
            luxTextView.setText("");
            parent.setGravity(Gravity.CENTER_VERTICAL);
            parent.addView(luxTextView, 0);
            AutoBrightnessController autoBrightnessChangedReceiver = new AutoBrightnessController(luxTextView);
            IntentFilter intentFilter = new IntentFilter(
                    AutoBrightnessController.ACTION_AUTO_BRIGHTNESS_CHANGED);
            intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
            parent.getContext().registerReceiver(autoBrightnessChangedReceiver, intentFilter);
        }
    });
}

From source file:com.allthingsgeek.celljoust.MainActivity.java

private synchronized void startListening() {
    Log.d(TAG, "startListening called");

    convWorker = new ConversionWorker();

    if (state == null) {
        state = new RobotStateHandler(handler);
        state.start();/* ww  w  .  ja  v a2s.  com*/
        while (state.handler == null) {
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
            }
        }

    }

    if (sensorListener == null) {
        sensorListener = new SensorListenerImpl(state.handler, wifiManager);
    }

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    RobotStateHandler.ROBOT_ID = settings.getString("ROBOT_ID", RobotStateHandler.ROBOT_ID);

    // Toast.makeText(CONTEXT, "Current IP:" + state.getLocalIpAddress(),
    // Toast.LENGTH_LONG);
    // ProgressDialog.show(me, msg,
    // "Searching for a Bluetooth serial port...");

    ProgressDialog btDialog = null;

    String connectivity_context = Context.WIFI_SERVICE;
    WifiManager wifi = (WifiManager) getSystemService(connectivity_context);

    this.registerReceiver(sensorListener.mBatInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    this.registerReceiver(sensorListener.mWifiInfoReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));

    if (OrientationManager.isSupported()) {
        OrientationManager.startListening(sensorListener);
    }

    if (LightSensorManager.isSupported()) {
        LightSensorManager.startListening(sensorListener);
    }

    if (CompassManager.isSupported()) {
        CompassManager.startListening(sensorListener);
    }

}

From source file:in.rade.armud.armudclient.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);

    // Locate the UI widgets.
    mLatitudeTextView = (TextView) findViewById(R.id.latitude_text);
    mLongitudeTextView = (TextView) findViewById(R.id.longitude_text);
    mLastUpdateTimeTextView = (TextView) findViewById(R.id.last_update_time_text);
    mLocInfoTextView = (TextView) findViewById(R.id.locinfo_text);
    mSubmitNameButton = (Button) findViewById(R.id.enterButton);
    mCharacterNameEdit = (EditText) findViewById(R.id.editName);

    // Set labels.
    mLatitudeLabel = getResources().getString(R.string.latitude_label);
    mLongitudeLabel = getResources().getString(R.string.longitude_label);
    mLastUpdateTimeLabel = getResources().getString(R.string.last_update_time_label);

    mRequestingLocationUpdates = true;//from ww  w . jav a 2 s  .com
    mLastUpdateTime = "";
    mLocInfoLabel = "";
    mConnected = false;
    amWaitingOnSubmit = false;
    mLoggedIn = false;
    mSubmitSuccess = false;

    mLatestLocAccuracy = 30;
    mRoomArrivalTime = 0;
    mCurrentRoom = "";

    // Add the project titles to display in a list for the listview adapter.

    // Initialise a listview adapter with the project titles and use it
    // in the listview to show the list of project.

    // Initialise TTS engine
    tts = new TextToSpeech(this, this);
    tts.setSpeechRate(1.2f);

    // Update values using data stored in the Bundle.
    updateValuesFromBundle(savedInstanceState);

    // Kick off the process of building a GoogleApiClient and requesting the LocationServices
    // API.
    buildGoogleApiClient();

    //getting gesture data from watchlistener service
    LocalBroadcastManager.getInstance(this).registerReceiver(mMsgFromWearReceiver,
            new IntentFilter(Globals.COMMAND_PATH));
    mReceiverRegistered = true;

    startService(new Intent(this, PhoneDataLayerListenerService.class));

    client.connect();

    mPrefs = getPreferences(MODE_PRIVATE);
    if (mPrefs.contains("LOGIN_STRING")) {
        mLoginString = mPrefs.getString("LOGIN_STRING", "connect test test");
        Log.d("login string", mLoginString);
        logintoMUD();
        mSubmitNameButton.setVisibility(View.GONE);
        mCharacterNameEdit.setVisibility(View.GONE);
        mLatitudeTextView.setText("");
    }
}

From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.services.transformationmanager.services.FelixService.java

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

    if (D)//from  w  w w .  ja v a  2  s. c o  m
        Log.d(TAG, "Setting up a thread for felix.");

    Thread felixThread = new Thread() {

        @Override
        public void run() {

            File dexOutputDir = getApplicationContext().getDir("transformationmanager", 0);

            // if default bundles were not installed already, install them
            File f = new File(dexOutputDir.getAbsolutePath() + "/bundle");
            if (!f.isDirectory()) {
                if (D)
                    Log.i(TAG, "Installing default bundles...");
                unzipBundles(FelixService.this.getResources().openRawResource(R.raw.bundles),
                        dexOutputDir.getAbsolutePath() + "/");
            }

            FelixConfig felixConfig = new FelixConfig(dexOutputDir.getAbsolutePath());
            Map<String, String> configProperties = felixConfig.getProperties2();

            try {
                FrameworkFactory frameworkFactory = new org.apache.felix.framework.FrameworkFactory();

                felixFramework = frameworkFactory.newFramework(configProperties);
                felixFramework.init();
                AutoProcessor.process(configProperties, felixFramework.getBundleContext());
                felixFramework.start();

                // Registering the android context as an osgi service
                Hashtable<String, String> properties = new Hashtable<String, String>();
                properties.put("platform", "android");
                felixFramework.getBundleContext().registerService(Context.class.getName(),
                        getApplicationContext(), properties);

            } catch (Exception ex) {
                Log.e(TAG, "Felix could not be started", ex);
                ex.printStackTrace();
            }
        }
    };

    felixThread.setDaemon(true);
    felixThread.start();

    LocalBroadcastManager.getInstance(this).registerReceiver(downloadReceiver,
            new IntentFilter(FELIX_SUCCESSFUL_WEB_REQUEST));
}

From source file:ca.uwaterloo.magic.goodhikes.MapsActivity.java

@Override
protected void onStart() {
    super.onStart();
    mFilter = new IntentFilter(GPSLoggingService.locationUpdateCommand);
    mGPSUpdatesReceiver = new GPSUpdatesReceiver();
    mConnection = new GPSLoggingServiceConnection();
    if (selectedRoute == null)
        selectedRoute = database.getLatestRoute(userManager.getUser());
    //        clearMap();
    LocalBroadcastManager.getInstance(this).registerReceiver(mGPSUpdatesReceiver, mFilter);
    registerReceiver(logoutReceiver, new IntentFilter("logout"));
    startService(new Intent(this, GPSLoggingService.class));
    Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; MapActivity started");
}

From source file:com.tweetlanes.android.view.TweetFeedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    mProfileImageLoader = getApp().getProfileImageLoader();
    mPreviewImageLoader = getApp().getPreviewImageLoader();

    mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(),
            getLaneIdentifier(), getApp().getCurrentAccountKey());

    View resultView = inflater.inflate(R.layout.lane, null);
    configureLaneWidth(resultView);// w ww . j  a  va  2  s .  com

    mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher);
    mListHeadingTextView = (TextView) resultView.findViewById(R.id.list_heading);
    mListHeadingHideImage = (ImageView) resultView.findViewById(R.id.list_hide);
    mListHeadingHideImage.setOnClickListener(mListHeadingHideImageOnClickListener);
    mMultipleTweetSelectionCallback = new MultipleTweetSelectionCallback();
    mTweetFeedListAdapter = new TweetFeedListAdapter(inflater);

    mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview);
    mTweetFeedListView.getRefreshableView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mTweetFeedListView.getRefreshableView().setMultiChoiceModeListener(mMultipleTweetSelectionCallback);
    mTweetFeedListView.getRefreshableView().setOnScrollListener(mTweetFeedOnScrollListener);
    mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter);
    mTweetFeedListView.setOnRefreshListener(mTweetFeedOnRefreshListener);
    mTweetFeedListView.setOnLastItemVisibleListener(mTweetFeedOnLastItemVisibleListener);

    configureInitialStatuses();

    mRefreshTimestampsHandler.removeCallbacks(mRefreshTimestampsTask);
    mRefreshTimestampsHandler.postDelayed(mRefreshTimestampsTask, REFRESH_TIMESTAMPS_INTERVAL);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeUpKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_UP_KEY_DOWN));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeDownKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN));

    return resultView;
}

From source file:ly.count.android.sdk.CrashDetails.java

/**
 * Returns the current device battery level.
 *//*from w  w w .j a  v  a  2s .  c o m*/
static String getBatteryLevel(Context context) {
    try {
        Intent batteryIntent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
        if (batteryIntent != null) {
            int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
            int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

            // Error checking that probably isn't needed but I added just in case.
            if (level > -1 && scale > 0) {
                return Float.toString(((float) level / (float) scale) * 100.0f);
            }
        }
    } catch (Exception e) {
        if (Countly.sharedInstance().isLoggingEnabled()) {
            Log.i(Countly.TAG, "Can't get batter level");
        }
    }

    return null;
}

From source file:eu.alefzero.owncloud.ui.fragment.FileDetailFragment.java

@Override
public void onResume() {
    super.onResume();
    mDownloadFinishReceiver = new DownloadFinishReceiver();
    IntentFilter filter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
    getActivity().registerReceiver(mDownloadFinishReceiver, filter);
    mPreview = (ImageView) mView.findViewById(R.id.fdPreview);
}