List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java
@Override public void onResume() { super.onResume(); updateSources();//from w w w .ja v a2 s . com IntentFilter packageChangeIntentFilter = new IntentFilter(); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED); packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageChangeIntentFilter.addDataScheme("package"); getActivity().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter); }
From source file:com.hsd.fsxasm.chat.activity.Jstx_MainActivity.java
private void registerBroadcastReceiver() { broadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED); intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED); broadcastReceiver = new BroadcastReceiver() { @Override//from w w w.j a v a 2s . c om public void onReceive(Context context, Intent intent) { updateUnreadLabel(); updateUnreadAddressLable(); if (currentTabIndex == 0) { // ?????? if (conversationListFragment != null) { conversationListFragment.refresh(); } } else if (currentTabIndex == 1) { if (contactListFragment != null) { contactListFragment.refresh(); } } String action = intent.getAction(); if (action.equals(Constant.ACTION_GROUP_CHANAGED)) { if (EaseCommonUtils.getTopActivity(Jstx_MainActivity.this) .equals(GroupsActivity.class.getName())) { GroupsActivity.instance.onResume(); } } } }; broadcastManager.registerReceiver(broadcastReceiver, intentFilter); }
From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java
@Override public void onResume() { super.onResume(); updateNotesTab();//from w w w .java2 s .c o m // Start listening for time updates to adjust "now" bar. TIME_TICK is // triggered once per minute, which is how we move the bar over time. final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_PACKAGE_ADDED); filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); getActivity().registerReceiver(mPackageChangesReceiver, filter); }
From source file:dk.ciid.android.infobooth.activities.SubscriptionFinalActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /* Variables received through Intent */ Intent openActivity = getIntent(); // this is just for example purpose isInDebugMode = openActivity.getBooleanExtra("isInDebugMode", true); // should the app send a welcome sms after subscribing? phoneNum = openActivity.getStringExtra("phoneNum"); // get the phonenumber submitted in the last activity selectedService = openActivity.getIntExtra("selectedService", 1); // array position of selected service in last activity serviceIdItems = openActivity.getStringArrayListExtra("serviceIdItems"); // arraylist of service id's (in database) serviceNameItems = openActivity.getStringArrayListExtra("serviceNameItems"); // arraylist of service names serviceDescItems = openActivity.getStringArrayListExtra("serviceDescItems"); // arraylist of service descriptions voice1 = openActivity.getStringExtra("voice1"); // path to voice file 1 voice2 = openActivity.getStringExtra("voice2"); // path to voice file 2 voice3 = openActivity.getStringExtra("voice3"); // path to voice file 3 voice4 = openActivity.getStringExtra("voice4"); // path to voice file 4 voice5 = openActivity.getStringExtra("voice5"); // path to voice file 5 voice6 = openActivity.getStringExtra("voice6"); // path to voice file 6 /* Variables received through Intent */ // TODO Auto-generated method stub super.onCreate(savedInstanceState); /* ARDUINO COMMUNICATION STUFF ********************************************/ // a reference to the USB system service is obtained so that you can call its methods later on mUsbManager = UsbManager.getInstance(this); mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); registerReceiver(mUsbReceiver, filter); if (getLastNonConfigurationInstance() != null) { mAccessory = (UsbAccessory) getLastNonConfigurationInstance(); openAccessory(mAccessory);//from www. jav a 2 s . com } /* ARDUINO COMMUNICATION STUFF ********************************************/ gestureScanner = new GestureDetector(this); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_subscription_final); if (!isInDebugMode) { try { //SmsManager smsManager = SmsManager.getDefault(); //smsManager.sendTextMessage(phoneNumber, null, SMSMessage, null, null); Toast.makeText(getApplicationContext(), "Thanks for subscribing!", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS failed, please try again later!", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Debug mode - no SMS sent to save money :)", Toast.LENGTH_SHORT) .show(); } // Set up sound playback initMediaPlayer(); }
From source file:com.mobicage.rogerthat.registration.YSAAARegistrationActivity.java
@Override protected void onServiceBound() { setContentView(R.layout.ysaaa_registration); mWiz = YSAAARegistrationWizard.getWizard(mService, Installation.id(this)); if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) { GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() { @Override/*from w w w . j av a2 s . c o m*/ public void idFound(String registrationId) { mGCMRegistrationId = registrationId; } }); } mStatusLbl = (TextView) findViewById(R.id.status); mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mTimer = new Timer(false); mRetryBtn = (Button) findViewById(R.id.retry_button); mRetryBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { register(); } }); final String[] receivingIntents = new String[] { FriendsPlugin.FRIENDS_LIST_REFRESHED, FriendsPlugin.FRIEND_UPDATE_INTENT, FriendsPlugin.FRIEND_ADDED_INTENT, BrandingMgr.SERVICE_BRANDING_AVAILABLE_INTENT, BrandingMgr.GENERIC_BRANDING_AVAILABLE_INTENT }; IntentFilter filter = new IntentFilter(); for (String action : receivingIntents) filter.addAction(action); registerReceiver(new SafeBroadcastReceiver() { @Override public String[] onSafeReceive(Context context, Intent intent) { T.UI(); launchMainActivityAndFinishIfAppReady(); return receivingIntents; }; }, filter); register(); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); Theme.checkTheme(this); mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main); StrictModeUtil.enable();/*from www . jav a 2s . c o m*/ // Set up the action bar. setSupportActionBar(mBinding.toolbarTabs.toolbar); ActionBar supportActionBar = getSupportActionBar(); assert supportActionBar != null; supportActionBar.setDisplayHomeAsUpEnabled(true); supportActionBar.setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mBinding.drawerLayout, /* DrawerLayout object */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */); // Explanation of setDrawerIndicatorEnabled and setHomeAsUpIndicator: // We want to only have a hamburger icon, always, without any animation. // If we don't call either of these methods, we use the default indicator, // which is the hamburger icon transitioning to a left-arrow icon, as the drawer is opened. // If we only call setDrawerIndicatorUpEnabled, we'll have the left arrow icon always. // If we only call setHomeAsUpIndicator (with a hamburger icon), we'll have a hamburger icon // but with a bug: If you open the drawer, rotate, and close it, you'll have the left arrow // again. // With the combination of both setDrawerIndicatorEnabled and setHomeAsUpIndicator, we // have a hamburger icon always. mDrawerToggle.setDrawerIndicatorEnabled(false); mDrawerToggle.setHomeAsUpIndicator(new DrawerArrowDrawable(this)); mMainPagerAdapter = new MainPagerAdapter(this, getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mBinding.pager.setAdapter(mMainPagerAdapter); mBinding.toolbarTabs.tabs.setupWithViewPager(mBinding.pager); // If our activity was opened by choosing a file from a mail attachment, file browser, or other program, // import the database from this file. Intent intent = getIntent(); if (intent != null) { if (Intent.ACTION_VIEW.equals(intent.getAction())) importDB(intent.getData()); } // Register various observers. mTeamsObserver = new TeamsObserver(this, mOnTeamsChangedListener); mOnTeamsChangedListener.onTeamsChanged(); mTeamsObserver.register(); mTeamNavigationMenu = new TeamNavigationMenu(this, mBinding.leftDrawer.getMenu()); mTeamNavigationMenu.load(); mBinding.leftDrawer.setNavigationItemSelectedListener(mOnNavigationItemSelectedListener); IntentFilter filter = new IntentFilter(ACTION_IMPORT_COMPLETE); filter.addAction(ACTION_EXPORT_COMPLETE); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mBroadcastReceiver, filter); }
From source file:com.t2.compassionMeditation.DeviceManagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mInstance = this; sharedPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); //this.sendBroadcast(new Intent(BioFeedbackService.ACTION_SERVICE_START)); this.setContentView(R.layout.device_manager_activity_layout); this.findViewById(R.id.bluetoothSettingsButton).setOnClickListener(this); Resources resources = this.getResources(); AssetManager assetManager = resources.getAssets(); try {/*from w ww.ja va2 s . co m*/ mSpineManager = SPINEFactory.createSPINEManager("SPINETestApp.properties", resources); } catch (InstantiationException e) { Log.e(TAG, this.getClass().getSimpleName() + " Exception creating SPINE manager: " + e.toString()); e.printStackTrace(); } // ... then we need to register a SPINEListener implementation to the SPINE manager instance // to receive sensor node data from the Spine server // (I register myself since I'm a SPINEListener implementation!) mSpineManager.addListener(this); // Create a broadcast receiver. Note that this is used ONLY for command messages from the service // All data from the service goes through the mail SPINE mechanism (received(Data data)). // See public void received(Data data) this.mCommandReceiver = new SpineReceiver(this); // Set up filter intents so we can receive broadcasts IntentFilter filter = new IntentFilter(); filter.addAction("com.t2.biofeedback.service.status.BROADCAST"); filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BioFeedbackService.ACTION_STATUS_BROADCAST); this.registerReceiver(this.mCommandReceiver, filter); // Tell the bluetooth service to send us a list of bluetooth devices and system status // Response comes in public void onStatusReceived(BioFeedbackStatus bfs) STATUS_PAIRED_DEVICES mSpineManager.pollBluetoothDevices(); // this.deviceManager = DeviceManager.getInstance(this.getBaseContext(), null); this.deviceList = (ListView) this.findViewById(R.id.list); this.deviceListAdapter = new ManagerItemAdapter(this, R.layout.manager_item); this.deviceList.setAdapter(this.deviceListAdapter); this.bluetoothDisabledDialog = new AlertDialog.Builder(this).setMessage("Bluetooth is not enabled.") .setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).setPositiveButton("Setup Bluetooth", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startBluetoothSettings(); } }).create(); try { PackageManager packageManager = this.getPackageManager(); PackageInfo info = packageManager.getPackageInfo(this.getPackageName(), 0); mVersionName = info.versionName; Log.i(TAG, this.getClass().getSimpleName() + " Spine server Test Application Version " + mVersionName); } catch (NameNotFoundException e) { Log.e(TAG, this.getClass().getSimpleName() + e.toString()); } }
From source file:arun.com.chromer.webheads.WebHeadService.java
private void registerReceivers() { final IntentFilter localEvents = new IntentFilter(); localEvents.addAction(ACTION_WEBHEAD_COLOR_SET); localEvents.addAction(ACTION_REBIND_WEBHEAD_TAB_CONNECTION); localEvents.addAction(ACTION_CLOSE_WEBHEAD_BY_URL); localEvents.addAction(ACTION_OPEN_CONTEXT_ACTIVITY); LocalBroadcastManager.getInstance(this).registerReceiver(localReceiver, localEvents); final IntentFilter notificationFilter = new IntentFilter(); notificationFilter.addAction(ACTION_STOP_WEBHEAD_SERVICE); notificationFilter.addAction(ACTION_OPEN_CONTEXT_ACTIVITY); notificationFilter.addAction(ACTION_OPEN_NEW_TAB); registerReceiver(notificationActionReceiver, notificationFilter); }
From source file:com.fysl.app.main.MainActivity.java
private void registerBroadcastReceiver() { broadcastManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constant.ACTION_CONTACT_CHANAGED); intentFilter.addAction(Constant.ACTION_GROUP_CHANAGED); broadcastReceiver = new BroadcastReceiver() { @Override/*w ww. j a v a 2 s. c o m*/ public void onReceive(Context context, Intent intent) { updateUnreadLabel(); updateUnreadAddressLable(); if (currentTabIndex == 2) { // ?????? if (conversationListFragment != null) { conversationListFragment.refresh(); } } else if (currentTabIndex == 3) { if (contactListFragment != null) { contactListFragment.refresh(); } } String action = intent.getAction(); if (action.equals(Constant.ACTION_GROUP_CHANAGED)) { if (EaseCommonUtils.getTopActivity(MainActivity.this).equals(GroupsActivity.class.getName())) { GroupsActivity.instance.onResume(); } } } }; broadcastManager.registerReceiver(broadcastReceiver, intentFilter); }
From source file:com.brucegiese.perfectposture.OrientationService.java
/** * Start monitoring the user's posture./* w ww. j ava2s . c om*/ */ private void startChecking() { mChinTuckReminderCounter = 0; mCurrentPostureGood = true; // start out assuming good posture mHysteresisCounter = 0; mBadPostureReminderCounter = 0; try { if (mOrientation.startOrienting()) { OrientationService.sIsRunning = true; if (mScheduledFuture == null) { // We use an additional thread for the periodic execution task. ScheduledExecutorService mScheduler = Executors.newScheduledThreadPool(1); mScheduledFuture = mScheduler.scheduleAtFixedRate(mDoPeriodicWork, UPDATE_INTERVAL, UPDATE_INTERVAL, TimeUnit.SECONDS); } else { Log.e(TAG, "startChecking() was called when checking was already running"); } } else { Toast.makeText(this, R.string.no_sensors, Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e(TAG, "Exception when starting orientation and scheduler: ", e); } // Register the broadcast receiver IntentFilter iFilter = new IntentFilter(); iFilter.addAction(TURN_OFF_SERVICE_ACTION); LocalBroadcastManager.getInstance(this).registerReceiver(mCommandReceiver, iFilter); }