List of usage examples for android.view Window FEATURE_ACTION_BAR_OVERLAY
int FEATURE_ACTION_BAR_OVERLAY
To view the source code for android.view Window FEATURE_ACTION_BAR_OVERLAY.
Click Source Link
From source file:com.synox.android.ui.preview.PreviewImageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.preview_image_activity); // Navigation Drawer initDrawer();// www . j a va 2 s .co m Toolbar fdToolbar = (Toolbar) findViewById(R.id.overlayToolbar); if (fdToolbar != null) { setSupportActionBar(fdToolbar); } updateActionBarTitleAndHomeButton(null); getSupportActionBar().hide(); // Make sure we're running on Honeycomb or higher to use FullScreen and // Immersive Mode if (isHoneycombOrHigher()) { mFullScreenAnchorView = getWindow().getDecorView(); // to keep our UI controls visibility in line with system bars // visibility mFullScreenAnchorView .setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @SuppressLint("InlinedApi") @Override public void onSystemUiVisibilityChange(int flags) { boolean visible = (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; if (visible) { getSupportActionBar().show(); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); } else { getSupportActionBar().hide(); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(getResources().getColor(android.R.color.black)); } } if (savedInstanceState != null) { mRequestWaitingForBinder = savedInstanceState.getBoolean(KEY_WAITING_FOR_BINDER); } else { mRequestWaitingForBinder = false; } }
From source file:com.android.gallery3d.app.Gallery.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.main);/*from w w w . j a v a2 s . c o m*/ mActionBar = new GalleryActionBar(this); if (savedInstanceState != null) { getStateManager().restoreFromState(savedInstanceState); } else { initializeByIntent(); } }
From source file:nf.frex.android.FrexActivity.java
/** * Called when the activity is first created. *//*from w w w . ja v a2 s. c om*/ @Override public void onCreate(Bundle savedInstanceState) { //Log.d(TAG, "onCreate(savedInstanceState=" + savedInstanceState + ")"); super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY); if (PRE_SDK14) { requestWindowFeature(Window.FEATURE_NO_TITLE); // Fix: Frex to stop working on screen orientation changes (Android 2.3.x only) if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else { getActionBar().setBackgroundDrawable(new PaintDrawable(Color.argb(128, 0, 0, 0))); } view = new FractalView(this); setContentView(view); if (!tryReadingFrexDocIntent(getIntent())) { if (savedInstanceState != null) { view.restoreInstanceState(new BundlePropertySet(savedInstanceState)); } else { PropertySet propertySet = (PropertySet) getLastNonConfigurationInstance(); if (propertySet != null) { view.restoreInstanceState(propertySet); } } } }
From source file:com.cgearc.yummy.Act_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.act_main);/* ww w . j a v a 2s .c o m*/ mAdView = (AdView) findViewById(R.id.ad); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice("1E172019E4D41AF1A4ED0C07934364B0").build(); mAdView.loadAd(adRequest); mTitle = mDrawerTitle = getTitle(); mDrawerItems = getResources().getStringArray(R.array.drawer_item_array); // now 3 mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener int[] image = { R.drawable.ic_menu_home, R.drawable.ic_action_search, R.drawable.ic_action_favorite, R.drawable.ic_action_about, R.drawable.ic_action_good }; List<Map<String, Object>> items = new ArrayList<Map<String, Object>>(); for (int i = 0; i < image.length; i++) { Map<String, Object> item = new HashMap<String, Object>(); item.put("image", image[i]); item.put("text", mDrawerItems[i]); items.add(item); } SimpleAdapter simpleAdapter = new SimpleAdapter(this, items, R.layout.drawer_list_item, new String[] { "image", "text" }, new int[] { R.id.drawer_image, R.id.drawer_text }); mDrawerList.setAdapter(simpleAdapter); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } @Override public void onDrawerSlide(View drawerView, float slideOffset) { BaseFragment fragment = (BaseFragment) Act_Main.this.getFragmentManager() .findFragmentById(R.id.content_frame); if (fragment != null) { fragment.stepBack(slideOffset); } } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } // SlidingUP ---start--- mSUPTitle = (TextView) findViewById(R.id.title); mSUPTitle.setText("Welcome Yummy!"); mSUPAuthor = (TextView) findViewById(R.id.author); mSUPAuthor.setText("Click above recipe and view detail here"); mSlideUpPanel = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); mDragView = (LinearLayout) this.findViewById(R.id.dragView); mSlideUpPanel.setDragView(mDragView); mSlideUpPanel.setPanelSlideListener(new PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { } @Override public void onPanelExpanded(View panel) { Log.i(TAG, "onPanelExpanded"); mImageButtonWeb.setVisibility(View.VISIBLE); mImageButtonClose.setVisibility(View.VISIBLE); toggleHideyBar(); // TODO: switch text with head and actionbar title // String title = mSUPTitle.getText().toString(); // mSUPTitle.setText(getActionBar().getTitle()); // setTitle(title); // mDragView.setVisibility(View.GONE); } @Override public void onPanelCollapsed(View panel) { Log.i(TAG, "onPanelCollapsed"); toggleHideyBar(); // getActionBar().show(); mImageButtonWeb.setVisibility(View.INVISIBLE); mImageButtonClose.setVisibility(View.INVISIBLE); // TODO: switch text with head and actionbar title // String title = mSUPTitle.getText().toString(); // mSUPTitle.setText(getActionBar().getTitle()); // setTitle(title); // mDragView.setVisibility(View.VISIBLE); } @Override public void onPanelAnchored(View panel) { Log.i(TAG, "onPanelAnchored"); } }); // boolean actionBarHidden = savedInstanceState != null // && savedInstanceState.getBoolean(SAVED_STATE_ACTION_BAR_HIDDEN, // false); // if (actionBarHidden) { // int actionBarHeight = getActionBarHeight(); // setActionBarTranslation(-actionBarHeight);// will "hide" an // // ActionBar // } // SlidingUP ----end---- // Detail Frame Head ----start---- mImageButtonClose = (ImageButton) findViewById(R.id.close); mImageButtonWeb = (ImageButton) findViewById(R.id.web); mImageButtonClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mSlideUpPanel.collapsePane(); } }); // Detail Frame head -----end----- }
From source file:com.example.google.walkway.MainActivity.java
@SuppressLint("InlinedApi") @Override// www. j a v a 2 s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.activity_main); mSelectedPlaceTypes.addAll(Arrays.asList(NAV_PLACE_TYPES)); mPlaces = retrievePlaces(); setupMapIfNeeded(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.app_name, R.string.app_name) { public void onDrawerClosed(View view) { // getActionBar().setTitle(mTitle); if (view.equals(mNavListView)) { // XXX no need to recreate the markers if the place // types haven't changed. mMap.clear(); mPlaces = retrievePlaces(); if (mPlaceViewPager != null) { mPlaceViewPager.getAdapter().notifyDataSetChanged(); mPlaceViewPager.requestLayout(); } addPlacesToMap(); setSelectedPlace(0); showPlacesOnMap(true); // overrides animation from // setSelectedPlace setupPlaceList(); } } public void onDrawerOpened(View drawerView) { // getActionBar().setTitle(mDrawerTitle); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); setupPlaceViewPager(); setupPlaceList(); setupNavList(); // Set the map padding once the UI views have dimensions. ViewTreeObserver observer = mDrawerLayout.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { removeListener(); // Pad the top of the map to accommodate the transparent action // bar. TypedValue tv = new TypedValue(); int actionbarHeight = 0; if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) { actionbarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } // Pad the bottom of the map to accommodate the place viewpager. int viewPagerHeight = 0; if (mPlaceViewPager != null) { viewPagerHeight = mPlaceViewPager.getHeight(); } // If the place list isn't in a DrawerLayout, pad the map for it. int placeListWidth = 0; // Use if listview overlays map. // if (mPlaceListView.getVisibility() == View.VISIBLE) { // placeListWidth = mPlaceListView.getWidth(); // } mMap.setPadding(0, actionbarHeight, placeListWidth, viewPagerHeight); // Once the map is ready, add the markers to it. addPlacesToMap(); showPlacesOnMap(false); setSelectedPlace(0); } @SuppressWarnings("deprecation") @SuppressLint("NewApi") private void removeListener() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mDrawerLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { mDrawerLayout.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } }); }
From source file:com.tenthbit.zoomimageview.sample.ViewPagerSampleActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override// w w w .ja va 2 s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* * Use full screen window and translucent action bar */ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().setBackgroundDrawable(new ColorDrawable(0xFF000000)); if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); getActionBar().setBackgroundDrawable(new ColorDrawable(0x88000000)); // Note: if you use ActionBarSherlock use here getSupportActionBar() } setContentView(R.layout.view_pager); ViewPager viewPager = (ViewPager) findViewById(R.id.zoomViewPager); viewPager.setAdapter(new SamplePagerAdapter()); // Add margin between pages (optional) viewPager.setPageMargin((int) getResources().getDisplayMetrics().density * 10); }
From source file:com.android.audiorecorder.ui.ImageViewActvity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); mFileDeleteHandlerThread = new HandlerThread("ImageView"); mFileDeleteHandlerThread.start();//from ww w . j a va2s . c o m mFileDeleteHandler = new Handler(mFileDeleteHandlerThread.getLooper(), mFileProcHandlerCallback); orientationEventListener = new MyOrientationEventListener(this); orientationEventListener.enable(); setContentView(R.layout.layout_image_view); rootView = (RotateLayout) findViewById(R.id.picture_view_root); /*rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);*/ //ImageCacheParams cacheParams = new ImageCacheParams(this, IMAGE_CACHE_DIR); final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int height = displayMetrics.heightPixels; final int width = displayMetrics.widthPixels; final int longest = (height > width ? height : width) * 2 / 3; mBitmapUtils = new BitmapUtils(this); mBitmapUtils.configDefaultBitmapConfig(Config.RGB_565); mBitmapUtils.configDefaultAutoRotation(true); mBitmapUtils.configDiskCacheEnabled(true); mBitmapUtils.configMemoryCacheEnabled(true); Intent intent = getIntent(); mGalleryViewPager = (GalleryViewPager) findViewById(R.id.viewer); pagerAdapter = new FilePagerAdapter(this, 100, 0, mBitmapUtils, null); mGalleryViewPager.setAdapter(pagerAdapter); mGalleryViewPager.setOffscreenPageLimit(1); final BitmapDisplayConfig bd = new BitmapDisplayConfig(); bd.setAutoRotation(true); bd.setBitmapConfig(Config.RGB_565); mGalleryViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int index) { mBitmapUtils.display(mGalleryViewPager.mCurrentView, pagerAdapter.getCurrentPath(0, 0)); /*ImageCache imageCache = mImageFetcher.getImageCache(); if(imageCache != null) { BitmapDrawable value = imageCache.getBitmapFromMemCache(pagerAdapter.getCurrentPath(0, mCurrentSelect)); if(value != null){ mGalleryViewPager.mCurrentView.setImageBitmap(value.getBitmap()); } } Log.i(TAG, "---> page index " + index + " select.");*/ } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int state) { if (ViewPager.SCROLL_STATE_IDLE == state) { mHandler.removeMessages(MSG_LOAD_BITMAP); mHandler.sendEmptyMessageDelayed(MSG_LOAD_BITMAP, 0); } } }); mHandler.removeMessages(MSG_LOAD_BITMAP); mHandler.sendEmptyMessageDelayed(MSG_LOAD_BITMAP, 50); }
From source file:com.saarang.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(com.saarang.samples.apps.iosched.R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager() .findFragmentById(com.saarang.samples.apps.iosched.R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_mainlayout); adjustMainLayoutForActionBar();/*from w w w. ja va 2 s. c o m*/ mPlayerContainer = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(com.saarang.samples.apps.iosched.R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); mTabsContentLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(com.saarang.samples.apps.iosched.R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin( getResources().getDimensionPixelSize(com.saarang.samples.apps.iosched.R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(com.saarang.samples.apps.iosched.R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById( com.saarang.samples.apps.iosched.R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(com.saarang.samples.apps.iosched.R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors( res.getColor(com.saarang.samples.apps.iosched.R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // Reload all other data in this activity reloadFromIntent(getIntent()); // Update layout based on current configuration updateLayout(getResources().getConfiguration()); // Set up action bar if (!mLoadFromExtras) { // Start sessions query to populate action bar navigation spinner getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }
From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); super.onCreate(savedInstanceState); setContentView(R.layout.activity_session_livestream); mIsTablet = UIUtils.isTablet(this); // Set up YouTube player mYouTubeFragment = (YouTubePlayerFragment) getFragmentManager().findFragmentById(R.id.livestream_player); mYouTubeFragment.initialize(Config.YOUTUBE_API_KEY, this); // Views that are common over all layouts mMainLayout = (LinearLayout) findViewById(R.id.livestream_mainlayout); adjustMainLayoutForActionBar();/* w w w.j a va 2 s . co m*/ mPlayerContainer = (LinearLayout) findViewById(R.id.livestream_player_container); mFullscreenCaptions = (FrameLayout) findViewById(R.id.fullscreen_captions); final LayoutParams params = (LayoutParams) mFullscreenCaptions.getLayoutParams(); params.setMargins(0, getActionBarHeightPx(), 0, getActionBarHeightPx()); mFullscreenCaptions.setLayoutParams(params); mTabsContentLayout = (LinearLayout) findViewById(R.id.livestream_tabs_layout); // Set up ViewPager and adapter ViewPager viewPager = (ViewPager) findViewById(R.id.livestream_pager); viewPager.setOffscreenPageLimit(2); viewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin_width)); mTabsAdapter = new TabsAdapter(getFragmentManager()); viewPager.setAdapter(mTabsAdapter); viewPager.setOnPageChangeListener(mTabsAdapter); if (mIsTablet) { // Tablet UI specific views mVideoLayout = (LinearLayout) findViewById(R.id.livestream_video_layout); } mTabsAdapter.addTab(getString(R.string.session_livestream_info), new SessionSummaryFragment(), TABNUM_SESSION_SUMMARY); mTabsAdapter.addTab(getString(R.string.session_livestream_captions), new SessionCaptionsFragment(), TABNUM_LIVE_CAPTIONS); // Set up sliding tabs w/ViewPager SlidingTabLayout slidingTabLayout = (SlidingTabLayout) findViewById(R.id.livestream_sliding_tabs); slidingTabLayout.setCustomTabView(R.layout.tab_indicator, android.R.id.text1); Resources res = getResources(); slidingTabLayout.setSelectedIndicatorColors(res.getColor(R.color.tab_selected_strip)); slidingTabLayout.setDistributeEvenly(true); slidingTabLayout.setViewPager(viewPager); // Reload all other data in this activity reloadFromIntent(getIntent()); // Update layout based on current configuration updateLayout(getResources().getConfiguration()); // Set up action bar if (!mLoadFromExtras) { // Start sessions query to populate action bar navigation spinner getLoaderManager().initLoader(SessionsQuery._TOKEN, null, this); mLivestreamAdapter = new LivestreamAdapter(getActionBar().getThemedContext()); } }
From source file:com.jigarmjoshi.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (SimpleDatabaseUtil.isFirstApplicationStart(this)) { Log.i(MainActivity.class.getSimpleName(), "creating database for the first time"); SQLiteSimple databaseSimple = new SQLiteSimple(this, DATABASE_VERSION); databaseSimple.create(Report.class, LastLocation.class); } else if (SimpleDatabaseUtil.isFirstStartOnAppVersion(this, DATABASE_VERSION)) { Log.i(MainActivity.class.getSimpleName(), "creating database for the first time for this version " + DATABASE_VERSION); SQLiteSimple databaseSimple = new SQLiteSimple(this, DATABASE_VERSION); databaseSimple.create(Report.class, LastLocation.class); }// www .j ava 2 s .c o m // initialize services EntryDao.getInstance(this); LastLocationDao.getInstance(this); // scheduler mgr = (AlarmManager) getSystemService(ALARM_SERVICE); Intent i = new Intent(this, LocationPoller.class); com.jigarmjoshi.service.LocationManager locationManager = com.jigarmjoshi.service.LocationManager .getInstance(getApplicationContext()); List<String> providers = locationManager.getAllProviders(); boolean fusedSupported = false; for (String provider : providers) { if (com.jigarmjoshi.service.LocationManager.FUSED_PROVIDER.equals(provider)) { fusedSupported = true; break; } } i.putExtra(LocationPoller.EXTRA_INTENT, new Intent(this, com.jigarmjoshi.reciever.LocationReceiver.class)); i.putExtra(LocationPoller.EXTRA_PROVIDER, (fusedSupported ? LocationManager.FUSED_PROVIDER : LocationManager.GPS_PROVIDER)); pi = PendingIntent.getBroadcast(this, 0, i, 0); mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 0, Long.parseLong(ConfigService.get(ConfigService.GPS_TASK_INTERVAL, "40000")), pi); // upload task Timer timer = new Timer(); TimerTask timerTask = new UploaderTask(this); timer.schedule(timerTask, 0, Long.parseLong(ConfigService.get(ConfigService.UPLOAD_TASK_INTERVAL, "40000"))); selectedTextView = new TextView(this); selectedTextView.setTextColor(Color.BLACK); selectedTextView.setGravity(Gravity.CENTER); selectedTextView.setPaintFlags(Paint.FAKE_BOLD_TEXT_FLAG); unSelectedTextView = new TextView(this); unSelectedTextView.setTextColor(Color.GRAY); unSelectedTextView.setGravity(Gravity.CENTER); unSelectedTextView.setPaintFlags(Paint.FAKE_BOLD_TEXT_FLAG); // create if first time getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); actionBar = getActionBar(); actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#40808080"))); actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#40808080"))); setContentView(R.layout.activity_main); // Initilization viewPager = (ViewPager) findViewById(R.id.pager); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Adding Tabs boolean first = false; for (String tab_name : tabs) { Tab tab = actionBar.newTab().setText(tab_name).setTabListener(this); if (first) { first = false; selectedTextView.setText(tab.getText().toString().toUpperCase(Locale.getDefault())); tab.setCustomView(selectedTextView); } else { unSelectedTextView.setText(tab.getText().toString().toUpperCase(Locale.getDefault())); tab.setCustomView(unSelectedTextView); } actionBar.addTab(tab); } /** * on swiping the viewpager make respective tab selected * */ viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page // make respected tab selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); Toast.makeText(this, getString(R.string.wait_gps), Toast.LENGTH_LONG).show(); }