List of usage examples for android.content BroadcastReceiver BroadcastReceiver
public BroadcastReceiver()
From source file:com.yangtsaosoftware.pebblemessenger.activities.SetupFragment.java
private void test_pebble_app(Context context) { BroadcastReceiver br = new BroadcastReceiver() { @Override/*from www .j a va2s. c o m*/ public void onReceive(Context context, Intent intent) { byte[] command = intent.getByteArrayExtra(Constants.BROADCAST_VERSION); boolean result = true; if (command == null || command[0] < Constants.PEBBLE_VERSION[0]) { result = false; } else if (command[1] < Constants.PEBBLE_VERSION[1]) { result = false; } else if (command[2] < Constants.PEBBLE_VERSION[2]) { result = false; } SpannableStringBuilder ssb = new SpannableStringBuilder(); ssb.append(textInfo.getText()); ssb.append(context.getString(R.string.setup_app_test)); ssb.append('\n'); ssb.append(context.getString(R.string.setup_install_pebble_app)); ssb.append((result ? greenText(R.string.setup_check_ok) : redText(R.string.setup_check_bad))); ssb.append('\n'); textInfo.setText(ssb); svMyview.fullScroll(View.FOCUS_DOWN); LocalBroadcastManager.getInstance(context).unregisterReceiver(this); } }; IntentFilter intentFilter = new IntentFilter(SetupFragment.class.getName()); LocalBroadcastManager.getInstance(context).registerReceiver(br, intentFilter); Intent inner_intent = new Intent(PebbleCenter.class.getName()); inner_intent.putExtra(Constants.BROADCAST_COMMAND, Constants.BROADCAST_PEBBLE_TEST); LocalBroadcastManager.getInstance(context).sendBroadcast(inner_intent); }
From source file:com.ephemeraldreams.gallyshuttle.ui.ScheduleActivity.java
/** * Register a {@link #networkStateBroadCastReceiver}, which monitor for Internet connection * re-establishment./*from w ww . j a v a 2 s.c o m*/ */ private void registerNetworkBroadcastReceiver() { networkStateBroadCastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // Internet connection has been re-established. unregisterNetworkBroadcastReceiver(); } }; registerReceiver(networkStateBroadCastReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); isNetworkStateBroadcastReceiverRegistered = true; }
From source file:com.mifos.mifosxdroid.activity.pathtracking.PathTrackingActivity.java
public void createNotificationReceiver() { notificationReceiver = new BroadcastReceiver() { @Override/* w w w .j ava2s. co m*/ public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Constants.STOP_TRACKING.equals(action)) { invalidateOptionsMenu(); pathTrackingPresenter.loadPathTracking(PrefManager.getUserId()); } } }; registerReceiver(notificationReceiver, new IntentFilter(Constants.STOP_TRACKING)); }
From source file:com.connectsdk.discovery.DiscoveryManager.java
/** * Create a new instance of DiscoveryManager. * Direct use of this constructor is not recommended. In most cases, * you should use DiscoveryManager.getInstance() instead. *///from w ww. ja v a 2 s.c o m public DiscoveryManager(Context context, ConnectableDeviceStore connectableDeviceStore) { this.context = context; this.connectableDeviceStore = connectableDeviceStore; allDevices = new ConcurrentHashMap<String, ConnectableDevice>(8, 0.75f, 2); compatibleDevices = new ConcurrentHashMap<String, ConnectableDevice>(8, 0.75f, 2); deviceClasses = new ConcurrentHashMap<String, Class<? extends DeviceService>>(4, 0.75f, 2); discoveryProviders = new CopyOnWriteArrayList<DiscoveryProvider>(); discoveryListeners = new CopyOnWriteArrayList<DiscoveryManagerListener>(); WifiManager wifiMgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); multicastLock = wifiMgr.createMulticastLock("Connect SDK"); multicastLock.setReferenceCounted(true); capabilityFilters = new ArrayList<CapabilityFilter>(); pairingLevel = PairingLevel.OFF; receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); switch (networkInfo.getState()) { case CONNECTED: if (mSearching) { for (DiscoveryProvider provider : discoveryProviders) { provider.start(); } } break; case DISCONNECTED: Log.w("Connect SDK", "Network connection is disconnected"); for (DiscoveryProvider provider : discoveryProviders) { provider.reset(); } allDevices.clear(); for (ConnectableDevice device : compatibleDevices.values()) { handleDeviceLoss(device); } compatibleDevices.clear(); for (DiscoveryProvider provider : discoveryProviders) { provider.stop(); } break; case CONNECTING: break; case DISCONNECTING: break; case SUSPENDED: break; case UNKNOWN: break; } } } }; registerBroadcastReceiver(); }
From source file:com.klinker.android.twitter.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); UpdateUtils.checkUpdate(this); MainActivity.sendHandler = new Handler(); context = this; sContext = this; sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0); DrawerActivity.settings = AppSettings.getInstance(context); try {/*from w w w . j av a 2s . c o m*/ requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); } catch (Exception e) { } sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false)) .commit(); setUpTheme(); setUpWindow(); setContentView(R.layout.main_activity); mViewPager = (ViewPager) findViewById(R.id.pager); setUpDrawer(0, getResources().getString(R.string.timeline)); MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout); MainActivity.sendHandler.postDelayed(showSend, 1000); MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button); MainActivity.sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent compose = new Intent(context, ComposeActivity.class); startActivity(compose); } }); actionBar = getActionBar(); if (!settings.isTwitterLoggedIn) { Intent login = new Intent(context, LoginActivity.class); startActivity(login); } mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs, getIntent().getBooleanExtra("from_launcher", false)); int currAccount = sharedPrefs.getInt("current_account", 1); int defaultPage = sharedPrefs.getInt("default_timeline_page_" + currAccount, 0); actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(defaultPage)); mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrollStateChanged(int state) { } public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (!actionBar.isShowing()) { actionBar.show(); if (translucent) { statusBar.setVisibility(View.VISIBLE); } } MainActivity.sendHandler.post(showSend); } public void onPageSelected(int position) { String title = "" + mSectionsPagerAdapter.getPageTitle(position); MainDrawerArrayAdapter.setCurrent(context, position); drawerList.invalidateViews(); actionBar.setTitle(title); } }); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER); mViewPager.setCurrentItem(defaultPage); MainDrawerArrayAdapter.setCurrent(this, defaultPage); drawerList.invalidateViews(); if (getIntent().getBooleanExtra("from_launcher", false)) { actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0))); } mViewPager.setOffscreenPageLimit(TimelinePagerAdapter.MAX_EXTRA_PAGES); if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) { getIntent().putExtra("tutorial", false); sharedPrefs.edit().putBoolean("done_tutorial", true).commit(); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "close drawer"); mDrawerLayout.closeDrawer(Gravity.LEFT); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "open drawer"); mDrawerLayout.openDrawer(Gravity.LEFT); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "page left"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT)); registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { try { Log.v("tutorial_activity", "page right"); mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true); unregisterReceiver(this); } catch (Exception e) { e.printStackTrace(); } } }, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT)); startActivity(new Intent(context, TutorialActivity.class)); overridePendingTransition(0, 0); } setLauncherPage(); if (getIntent().getBooleanExtra("from_drawer", false)) { mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 1)); } }
From source file:bf.io.openshop.ux.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mInstance = this; Timber.d("%s onCreate", MainActivity.class.getSimpleName()); // Set app specific language localization by selected shop. String lang = SettingsMy.getActualNonNullShop(this).getLanguage(); MyApplication.setAppLocale(lang);//from w ww .j a v a 2 s .c om setContentView(R.layout.activity_main); // if (BuildConfig.DEBUG) { // // Only debug properties, used for checking image memory management. // Picasso.with(this).setIndicatorsEnabled(true); // Picasso.with(this).setLoggingEnabled(true); // } // Initialize trackers and fbLogger Analytics.prepareTrackersAndFbLogger(SettingsMy.getActualNonNullShop(this), getApplicationContext()); // Prepare toolbar and navigation drawer Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(true); } else { Timber.e(new RuntimeException(), "GetSupportActionBar returned null."); } drawerFragment = (DrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.main_navigation_drawer_fragment); drawerFragment.setUp((DrawerLayout) findViewById(R.id.main_drawer_layout), toolbar, this); // Initialize list for search suggestions searchSuggestionsList = new ArrayList<>(); // GCM registration // mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean sentToken = SettingsMy.getTokenSentToServer(); if (sentToken) { Timber.d("Gcm registration success."); } else { Timber.e("Gcm registration failed. Device isn't registered on server."); } } }; registerGcmOnServer(); // end of GCM registration // addInitialFragment(); // Opened by notification with some data if (this.getIntent() != null && this.getIntent().getExtras() != null) { String target = this.getIntent().getExtras().getString(CONST.BUNDLE_PASS_TARGET, ""); String title = this.getIntent().getExtras().getString(CONST.BUNDLE_PASS_TITLE, ""); Timber.d("Start notification with banner target: %s", target); Banner banner = new Banner(); banner.setTarget(target); banner.setName(title); onBannerSelected(banner); Analytics.logOpenedByNotification(target); } }
From source file:com.mjhram.ttaxi.GpsMainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); tracer = LoggerFactory.getLogger(GpsMainActivity.class.getSimpleName()); loadPresetProperties();// w ww . java2 s . co m setContentView(R.layout.activity_gps_main); pDialog = new ProgressDialog(this); pDialog.setCancelable(false); btnPickDrop = (Button) findViewById(R.id.btnPickDrop); driverInfoLayout = (RelativeLayout) findViewById(R.id.driverLayout); driverInfoLayout.setVisibility(View.INVISIBLE); txtDriverName = (TextView) findViewById(R.id.textViewDriverName); txtDriverInfo = (TextView) findViewById(R.id.textViewDriverInfo); networkImageViewDriver = (NetworkImageView) findViewById(R.id.imageViewDriver); btnDriverPhone = (Button) findViewById(R.id.btnDriverPhone); btnDriverPhone.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri number = Uri.parse("tel:" + btnDriverPhone.getText()); Intent callIntent = new Intent(Intent.ACTION_DIAL, number); startActivity(callIntent); } }); relativeLayoutAds = (RelativeLayout) findViewById(R.id.relativeLayoutAds); btnAdsX = (ImageButton) findViewById(R.id.btnAdsX); btnAdsX.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { relativeLayoutAds.setVisibility(View.GONE); } }); textviewAds = (TextView) findViewById(R.id.textview_ads); networkivAds = (NetworkImageView) findViewById(R.id.networkivAds); /*{ //final String IMAGE_URL = "http://developer.android.com/images/training/system-ui.png"; ImageLoader mImageLoader = AppSettings.getInstance().getImageLoader(); networkivAds.setImageUrl(Constants.URL_ads+".jpg", mImageLoader); }*/ mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //new TReq arrived int drvId = intent.getIntExtra("drvId", -1); //updateRequests(treqId); } }; buildGoogleApiClient(); /*mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(LocationServices.API) //.addConnectionCallbacks(this) //.addOnConnectionFailedListener(this) .build();*/ SetUpToolbar(); SetUpNavigationDrawer(); /*StartAndBindService(); if(AppSettings.shouldStartLoggingOnAppLaunch()){ tracer.debug("Start logging on app launch"); EventBus.getDefault().postSticky(new CommandEvents.RequestStartStop(true)); }*/ if (AppSettings.shouldUploadRegId) { AppSettings.shouldUploadRegId = false; updateRegId(AppSettings.getUid(), AppSettings.regId); } UploadClass uc = new UploadClass(this); uc.getPassangerState(AppSettings.getUid()); }
From source file:com.zentri.zentri_ble_command_demo.DeviceInfoActivity.java
private void initBroadcastReceiver() { mBroadcastReceiver = new BroadcastReceiver() { @Override/*from w w w . j a v a 2 s . co m*/ public void onReceive(Context context, Intent intent) { // Get extra data included in the Intent String action = intent.getAction(); switch (action) { case ZentriOSBLEService.ACTION_COMMAND_SENT: String command = ZentriOSBLEService.getCommand(intent).toString(); Log.d(TAG, "Command " + command + " sent"); break; case ZentriOSBLEService.ACTION_COMMAND_RESULT: handleCommandResponse(intent); break; case ZentriOSBLEService.ACTION_MODE_WRITE: int mode = ZentriOSBLEService.getMode(intent); if (mode == ZentriOSBLEManager.MODE_STREAM) { //disable buttons while in stream mode (must be in rem command to work) GUISetStreamMode(); } else { GUISetCommandMode(); } break; case ZentriOSBLEService.ACTION_STRING_DATA_READ: if (mCurrentMode == ZentriOSBLEManager.MODE_STREAM) { String text = ZentriOSBLEService.getData(intent); updateReceivedTextBox(text); } break; case ZentriOSBLEService.ACTION_ERROR: ErrorCode errorCode = ZentriOSBLEService.getErrorCode(intent); //handle errors switch (errorCode) { case DEVICE_ERROR: //connection state change without request if (mDisconnecting) { mDisconnecting = false; dismissProgressDialog(); showErrorDialog(R.string.error, R.string.device_error_message); } break; case DISCONNECT_FAILED: mDisconnecting = false; dismissProgressDialog(); showDisconnectErrorDialog(R.string.error, R.string.discon_err_message); break; } break; case ZentriOSBLEService.ACTION_DISCONNECTED: mHandler.removeCallbacks(mDisconnectTimeoutTask);//cancel timeout dismissProgressDialog(); finish(); break; } } }; }
From source file:de.winniehell.battlebeavers.ui.GameListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.game_list_activity); final Settings settings = ((App) getApplication()).getSettings(); Log.d(TAG, "This is player " + settings.getPlayer().getId()); Intent intent = new Intent(GameListActivity.this, Client.class); if (!bindService(intent, client, Service.BIND_AUTO_CREATE)) { Log.e(TAG, getString(R.string.error_binding_client)); return;/* w w w.j a v a 2s . c o m*/ } intent = new Intent(GameListActivity.this, Server.class); if (!bindService(intent, server, Service.BIND_AUTO_CREATE)) { Log.e(TAG, getString(R.string.error_binding_server)); return; } announcedGames = new GameListView(this) { @Override protected void onPrepareContextMenu(final MenuInflater pInflater, final ContextMenu pMenu, final Game pGame) { pInflater.inflate(R.menu.context_announced_game, pMenu); pMenu.findItem(R.id.context_menu_join) .setVisible(pGame.isInState(GameListActivity.this, GameState.ANNOUNCED) && !pGame.isServer(getSettings().getPlayer())); } @Override public boolean onMenuItemClick(final MenuItem pItem) { final Game game = getSelectedItem(); if (game == null) { return false; } setSelection(-1); switch (pItem.getItemId()) { case R.id.context_menu_join: { Log.d(TAG, "Trying to join " + game + "..."); try { client.getService().joinGame(game); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } tabHost.setCurrentTabByTag(TAB_RUNNING); return true; } default: return false; } } }; announcedGames.setAdapter(new GameListAdapter() { @Override protected Game[] fetchList() { try { return client.getService().getAnnouncedGames(); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } return null; } }); runningGames = new GameListView(this) { @Override protected void onPrepareContextMenu(final MenuInflater pInflater, final ContextMenu pMenu, final Game pGame) { pInflater.inflate(R.menu.context_running_game, pMenu); pMenu.findItem(R.id.context_menu_load_game).setVisible(pGame.isInState(GameListActivity.this, GameState.PLANNING_PHASE, GameState.EXECUTION_PHASE)); } @Override public boolean onMenuItemClick(final MenuItem pItem) { final Game game = getSelectedItem(); if (game == null) { return false; } setSelection(-1); switch (pItem.getItemId()) { case R.id.context_menu_load_game: { showGame(game); return true; } default: return false; } } }; runningGames.setAdapter(new GameListAdapter() { @Override protected Game[] fetchList() { try { return client.getService().getRunningGames(); } catch (final RemoteException e) { ((ClientRemoteException) e).log(); } return null; } }); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); addTab(TAB_RUNNING, R.string.menu_running_games, runningGames); addTab(TAB_ANNOUNCED, R.string.menu_announced_games, announcedGames); tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(final String tabId) { updateGameList(); } }); tabHost = (TabHost) findViewById(android.R.id.tabhost); updateReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { updateGameList(); } }; Log.d(TAG, "onCreate() finished"); }
From source file:com.hypodiabetic.happ.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); activity = this; super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); ins = this;/* w w w .jav a2s . co m*/ PreferenceManager.setDefaultValues(this, R.xml.pref_aps, false); //Sets default APS Preferences if the user has not //xdrip start prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); checkEula(); startService(new Intent(getApplicationContext(), DataCollectionService.class)); PreferenceManager.setDefaultValues(this, R.xml.pref_general, false); PreferenceManager.setDefaultValues(this, R.xml.pref_bg_notification, false); //xdrip end setContentView(R.layout.activity_main); extendedGraphBuilder = new ExtendedGraphBuilder(this); //Setup menu tickWhite = getDrawable(R.drawable.checkbox_marked_circle); clockWhite = getDrawable(R.drawable.clock); tickWhite.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); clockWhite.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); insulinIntegrationApp_status = (TextView) findViewById(R.id.insulinIntegrationApp_status); insulinIntegrationApp_icon = (ImageView) findViewById(R.id.insulinIntegrationApp_icon); mDrawerList = (ListView) findViewById(R.id.navList); String[] osArray = { "Cancel Temp", "Settings", "Integration Report" }; mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, osArray); mDrawerList.setAdapter(mAdapter); mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: pumpAction.cancelTempBasal(MainActivity.activity); break; case 1: startActivity(new Intent(getApplicationContext(), SettingsActivity.class)); break; case 2: startActivity(new Intent(getApplicationContext(), Integration_Report.class)); break; } mDrawerLayout.closeDrawers(); } }); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLinear = (LinearLayout) findViewById(R.id.left_drawer); mActivityTitle = getTitle().toString(); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.getInstace()); Date now = new Date(); Profile p = new Profile(now, MainActivity.getInstace()); //Local device based Integrations String insulin_Integration_App = prefs.getString("insulin_integration", ""); //Insulin Integration App, try and connect if (!insulin_Integration_App.equals("")) { InsulinIntegrationApp insulinIntegrationApp = new InsulinIntegrationApp( MainActivity.getInstace(), insulin_Integration_App, "TEST"); insulinIntegrationApp.connectInsulinTreatmentApp(); insulinIntegrationApp_status.setText("Connecting..."); insulinIntegrationApp_icon.setBackground(clockWhite); //listens out for connection insulinIntegrationAppUpdate = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { insulinIntegrationApp_status.setText(intent.getStringExtra("MSG")); insulinIntegrationApp_icon.setBackground(tickWhite); } }; LocalBroadcastManager.getInstance(MainActivity.getInstace()).registerReceiver( insulinIntegrationAppUpdate, new IntentFilter("INSULIN_INTEGRATION_TEST")); } else { insulinIntegrationApp_status.setText("No app selected or not in Closed Loop"); insulinIntegrationApp_icon.setBackgroundResource(R.drawable.alert_circle); } } /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerToggle.syncState(); mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerLayout.setDrawerListener(mDrawerToggle); // Create the adapter that will return a fragment for each of the 4 primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) this.findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); //mViewPager.setOffscreenPageLimit(4); //Do not destroy any Fragments, // TODO: 14/09/2015 casues an issue with bvb chart rendering, not sure why //Build Fragments openAPSFragmentObject = new openAPSFragment(); iobcobActiveFragmentObject = new iobcobActiveFragment(); iobcobFragmentObject = new iobcobFragment(); basalvsTempBasalObject = new basalvsTempBasalFragment(); //Updates notifications every 60 seconds updateEvery60Seconds = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { APSResult apsResult = APSResult.last(); Notifications.updateCard(context, apsResult); } }; registerReceiver(updateEvery60Seconds, new IntentFilter(Intent.ACTION_TIME_TICK)); }