Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR.

Prototype

int SCREEN_ORIENTATION_SENSOR

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR.

Click Source Link

Document

Constant corresponding to sensor in the android.R.attr#screenOrientation attribute.

Usage

From source file:com.google.cast.samples.games.spellcast.MainActivity.java

public void showFragment(Fragment fragment) {
    Fragment currentFragment = getFragmentManager().findFragmentById(R.id.fragment_container);
    mNextFragment = null;/* w  ww . ja v a2  s. c o m*/
    if (currentFragment == fragment) {
        return;
    }
    if (isChangingConfigurations() || isFinishing() || isDestroyed()) {
        mNextFragment = fragment;
    } else {
        // We need to request the orientation change before we perform the fragment transition,
        // otherwise the fragment would start in the wrong orientation.
        if (fragment == mCombatFragment) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        }
        getFragmentManager().beginTransaction().replace(R.id.fragment_container, fragment)
                .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
    }
}

From source file:divya.myvision.TessActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *//*from w ww.  java 2 s.  co m*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.ocr_capture);

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<TessGraphic>) findViewById(R.id.graphicOverlay);

    // read parameters from the intent used to launch the activity.
    boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
    String fps = getIntent().getStringExtra(FPS);
    String fontSize = getIntent().getStringExtra(FontSize);
    String orientation = getIntent().getStringExtra(Orientation);
    String lang = getIntent().getStringExtra(Lang);

    if (orientation.equals("Landscape")) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals("Portrait")) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    Settings.setFontSize(Float.parseFloat(fontSize));

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash, fps);
    } else {
        requestCameraPermission();
    }

    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    Snackbar.make(mGraphicOverlay, R.string.info_msg, Snackbar.LENGTH_LONG).show();

    setLang(lang);
}

From source file:org.LK8000.LK8000.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (serviceClass == null)
        serviceClass = MyService.class;

    super.onCreate(savedInstanceState);
    //    Fabric.with(this, new Crashlytics(), new CrashlyticsNdk());

    Fabric fabric = new Fabric.Builder(this).debuggable(true).kits(new Crashlytics(), new CrashlyticsNdk())
            .build();//from   w ww .j a  v  a  2 s  . c  o m

    Fabric.with(fabric);

    Log.d(TAG, "ABI=" + Build.CPU_ABI);
    Log.d(TAG, "PRODUCT=" + Build.PRODUCT);
    Log.d(TAG, "MANUFACTURER=" + Build.MANUFACTURER);
    Log.d(TAG, "MODEL=" + Build.MODEL);
    Log.d(TAG, "DEVICE=" + Build.DEVICE);
    Log.d(TAG, "BOARD=" + Build.BOARD);
    Log.d(TAG, "FINGERPRINT=" + Build.FINGERPRINT);

    if (!Loader.loaded) {
        TextView tv = new TextView(this);
        tv.setText("Failed to load the native LK8000 libary.\n"
                + "Report this problem to us, and include the following information:\n" + "ABI=" + Build.CPU_ABI
                + "\n" + "PRODUCT=" + Build.PRODUCT + "\n" + "FINGERPRINT=" + Build.FINGERPRINT + "\n"
                + "error=" + Loader.error);
        setContentView(tv);
        return;
    }

    initialiseNative();

    NetUtil.initialise(this);
    InternalGPS.Initialize();
    NonGPSSensors.Initialize();

    IOIOHelper.onCreateContext(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR)
        // Bluetooth suppoert was added in Android 2.0 "Eclair"
        BluetoothHelper.Initialize(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)
        // the DownloadManager was added in Android 2.3 "Gingerbread"
        DownloadUtil.Initialise(getApplicationContext());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        UsbSerialHelper.Initialise(this);
    }

    SoundUtil.Initialise();

    // fullscreen mode
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().addFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    /* Workaround for layout problems in Android KitKat with immersive full
       screen mode: Sometimes the content view was not initialized with the
       correct size, which caused graphics artifacts. */
    if (android.os.Build.VERSION.SDK_INT >= 19) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
                | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
                | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    }

    enableImmersiveModeIfSupported();

    TextView tv = new TextView(this);
    tv.setText("Loading LK8000...");
    setContentView(tv);

    batteryReceiver = new BatteryReceiver();
    registerReceiver(batteryReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    SharedPreferences settings = getSharedPreferences("LK8000", 0);
    int screenOrientation = settings.getInt("screenOrientation", 0);
    switch (screenOrientation) {
    case 0:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        break;
    case 1:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case 2:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case 3:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        break;
    case 4:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        break;
    default:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

}

From source file:com.example.android.weatherapp.view.MainActivity.java

/**
 * to prevent crash on screen orientation in middle of network operation
 * we will be unlocking orientation after locking of screen was done.
 *
 * @author swapnil/*from   ww  w. j a  va2  s  .c  o  m*/
 */
private void unlockScreenOrientation() {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}

From source file:free.rm.skytube.gui.activities.YouTubePlayerActivity.java

@Override
protected void onStart() {
    super.onStart();

    // set the video player's orientation as what the user wants
    String str = SkyTubeApp.getPreferenceManager().getString(getString(R.string.pref_key_screen_orientation),
            getString(R.string.pref_screen_auto_value));
    int orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

    if (str.equals(getString(R.string.pref_screen_landscape_value)))
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
    if (str.equals(getString(R.string.pref_screen_portrait_value)))
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
    if (str.equals(getString(R.string.pref_screen_sensor_value)))
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;

    setRequestedOrientation(orientation);
}

From source file:com.rfo.basic.Web.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void setOrientation(int orientation) { // Convert and apply orientation setting
    switch (orientation) {
    default:// w  ww .  j ava2 s .  com
    case 1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    case 3:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        break;
    case 0:
        orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;
    case 2:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        break;
    case -1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
        break;
    }
    setRequestedOrientation(orientation);
}

From source file:org.openremote.android.console.GroupActivity.java

/**
 * Inits a orientation listener, set request orientation be sensor when the current screen's orientation equals device orientation.
 *///w ww .j  av  a  2s.  c  o m
private void initOrientationListener() {
    OrientationEventListener orientationListener = new OrientationEventListener(this) {
        @Override
        public void onOrientationChanged(int orientation) {
            if (currentScreen == null) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                return;
            }
            if (orientation > 315 || orientation < 45 || (orientation > 135 && orientation < 225)) {
                // portrait
                if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                        && !currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                } else if (!currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                }
            } else if ((orientation > 225 && orientation < 315) || (orientation > 45 && orientation < 135)) {
                // landscape
                if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                        && currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                } else if (currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                }
            }
        }
    };
    orientationListener.enable();
}

From source file:com.sip.pwc.sipphone.ui.SipHome.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //prefWrapper = new PreferencesWrapper(this);
    prefProviderWrapper = new PreferencesProviderWrapper(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.sip_home);//from w  w w .  j  ava 2  s.  co m

    final ActionBar ab = getSupportActionBar();
    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    Tab dialerTab = ab.newTab().setContentDescription(R.string.dial_tab_name_text)
            .setIcon(R.mipmap.ic_ab_dialer_holo_dark);
    Tab callLogTab = ab.newTab().setContentDescription(R.string.calllog_tab_name_text)
            .setIcon(R.mipmap.ic_ab_history_holo_dark);

    warningTab = ab.newTab().setIcon(android.R.drawable.ic_dialog_alert);
    warningTabfadeAnim = ObjectAnimator.ofInt(warningTab.getIcon(), "alpha", 255, 100);
    warningTabfadeAnim.setDuration(1500);
    warningTabfadeAnim.setRepeatCount(ValueAnimator.INFINITE);
    warningTabfadeAnim.setRepeatMode(ValueAnimator.REVERSE);

    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(dialerTab, DialerFragment.class, TAB_ID_DIALER);
    mTabsAdapter.addTab(callLogTab, CallLogListFragment.class, TAB_ID_CALL_LOG);

    hasTriedOnceActivateAcc = false;

    if (!prefProviderWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    selectTabWithAction(getIntent());
    Log.setLogLevel(prefProviderWrapper.getLogLevel());

    // Async check
    asyncSanityChecker = new Thread() {
        public void run() {
            asyncSanityCheck();
        };
    };
    asyncSanityChecker.start();

}

From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    try {//w  w w. j av  a 2s.co m
        DataFramework.getInstance().open(this, Utils.packageName);
    } catch (Exception e) {
        e.printStackTrace();
    }

    super.onCreate(savedInstanceState);

    CacheData.getInstance().fillHide();

    ConnectionManager.getInstance().open(this);
    ConnectionManager.getInstance().loadUsers();

    OnAlarmReceiver.callAlarm(this);

    if (PreferenceUtils.getFinishForceClose(this)) {
        PreferenceUtils.setFinishForceClose(this, false);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.title_crash);
        builder.setMessage(R.string.msg_crash);
        builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                Utils.sendLastCrash(TweetTopicsActivity.this);
            }
        });
        builder.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            }
        });
        builder.create();
        builder.show();
    }

    Thread.UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();
    if (currentHandler != null) {
        Thread.setDefaultUncaughtExceptionHandler(new ErrorReporter(currentHandler, getApplication()));
    }

    if (PreferenceManager.getDefaultSharedPreferences(this).getString("prf_orientation", "2").equals("2")) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    // borrar notificaciones
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("prf_notif_delete_notifications_inside",
            true)) {
        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();
    }

    long goToColumnPosition = -1;
    int goToColumnType = -1;
    long goToColumnUser = -1;
    long goToColumnSearch = -1;
    long selectedTweetId = -1;

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_POSITION)) {
            goToColumnPosition = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_POSITION);
        }
        if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_TYPE)) {
            goToColumnType = extras.getInt(KEY_EXTRAS_GOTO_COLUMN_TYPE);
        }
        if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_USER)) {
            goToColumnUser = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_USER);
        }
        if (extras.containsKey(KEY_EXTRAS_GOTO_COLUMN_SEARCH)) {
            goToColumnSearch = extras.getLong(KEY_EXTRAS_GOTO_COLUMN_SEARCH);
        }
        if (extras.containsKey(KEY_EXTRAS_GOTO_TWEET_ID)) {
            selectedTweetId = extras.getLong(KEY_EXTRAS_GOTO_TWEET_ID);
        }
    }

    int positionFromSensor = -1;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SAVE_STATE_COLUMN_POS)) {
        positionFromSensor = savedInstanceState.getInt(KEY_SAVE_STATE_COLUMN_POS);
    }

    Utils.createDirectoriesIfIsNecessary();

    Display display = getWindowManager().getDefaultDisplay();
    widthScreen = display.getWidth();
    heightScreen = display.getHeight();

    themeManager = new ThemeManager(this);
    themeManager.setTheme();

    setContentView(R.layout.tweettopics_activity);

    fragmentAdapter = new TweetTopicsFragmentAdapter(this, getSupportFragmentManager());

    pager = (ViewPager) findViewById(R.id.tweet_pager);
    pager.setAdapter(fragmentAdapter);

    indicator = (TitlePageIndicator) findViewById(R.id.tweettopics_bar_indicator);
    indicator.setFooterIndicatorStyle(TitlePageIndicator.IndicatorStyle.Triangle);
    indicator.setFooterLineHeight(0);
    indicator.setFooterColor(Color.WHITE);
    indicator.setClipPadding(-getWindowManager().getDefaultDisplay().getWidth());
    indicator.setViewPager(pager);
    indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i1) {
        }

        @Override
        public void onPageSelected(int i) {
            reloadBarAvatar();
            if (i == 0) {
                refreshMyActivity();
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {

        }
    });
    indicator.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showActionBarColumns();
        }
    });

    findViewById(R.id.tweettopics_bar_my_activity).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showActionBarIndicatorAndMovePager(0);
        }
    });

    findViewById(R.id.tweettopics_bar_options).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showMenuColumnsOptions(view);
        }
    });

    layoutOptionsColumns = (LinearLayout) findViewById(R.id.tweettopics_ll_options_columns);
    layoutMainOptionsColumns = (LinearLayout) findViewById(R.id.tweettopics_ll_main_options_columns);
    layoutMainOptionsColumns.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            hideOptionsColumns();
        }
    });
    btnOptionsColumnsMain = (Button) findViewById(R.id.tweettopics_ll_options_columns_btn_main);
    btnOptionsColumnsMain.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int pos = Integer.valueOf(view.getTag().toString());
            Toast.makeText(TweetTopicsActivity.this,
                    getString(R.string.column_main_message, fragmentAdapter.setColumnActive(pos)),
                    Toast.LENGTH_LONG).show();
            hideOptionsColumns();
        }
    });
    btnOptionsColumnsEdit = (Button) findViewById(R.id.tweettopics_ll_options_columns_btn_edit);
    btnOptionsColumnsEdit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            int pos = Integer.valueOf(view.getTag().toString());
            EditColumnDialogFragment frag = new EditColumnDialogFragment(
                    fragmentAdapter.getFragmentList().get(pos), new Callable() {
                        @Override
                        public Object call() throws Exception {
                            refreshActionBarColumns();
                            return null;
                        }
                    });
            frag.show(getSupportFragmentManager(), "dialog");
            hideOptionsColumns();
        }
    });

    // cargar el popup de enlaces

    FrameLayout root = ((FrameLayout) findViewById(R.id.tweettopics_root));
    popupLinks = new PopupLinks(this);
    popupLinks.loadPopup(root);

    splitActionBarMenu = new SplitActionBarMenu(this);
    splitActionBarMenu.loadSplitActionBarMenu(root);

    layoutBackgroundApp = (RelativeLayout) findViewById(R.id.tweettopics_layout_background_app);

    layoutBackgroundBar = (RelativeLayout) findViewById(R.id.tweettopics_bar_background);

    horizontalScrollViewColumns = (HorizontalScrollView) findViewById(R.id.tweettopics_bar_horizontal_scroll);

    layoutBackgroundColumnsBarContainer = (LinearLayout) findViewById(R.id.tweettopics_bar_columns_container);

    layoutBackgroundColumnsBar = (LinearLayout) findViewById(R.id.tweettopics_bar_columns);
    //        layoutBackgroundColumnsBar.setCols(4);
    //
    //        layoutBackgroundColumnsBar.setOnRearrangeListener(new OnRearrangeListener() {
    //            public void onRearrange(int oldIndex, int newIndex) {
    //                reorganizeColumns(oldIndex, newIndex);
    //            }
    //
    //            @Override
    //            public void onStartDrag(int x, int index) {
    //                showOptionsColumns(x, index, true);
    //            }
    //
    //            @Override
    //            public void onMoveDragged(int index) {
    //                hideOptionsColumns();
    //            }
    //
    //        });
    //        layoutBackgroundColumnsBar.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    //            @Override
    //            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    //                showActionBarIndicatorAndMovePager(position);
    //            }
    //        });

    imgBarAvatar = (ImageView) findViewById(R.id.tweettopics_bar_avatar);
    imgBarAvatarBg = (ImageView) findViewById(R.id.tweettopics_bar_avatar_bg);
    imgBarCounter = (TextView) findViewById(R.id.tweettopics_bar_counter);
    imgNewStatus = (ImageView) findViewById(R.id.tweettopics_bar_new_status);
    imgNewStatus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            newStatus();
        }
    });

    imgBarAvatarGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public void onLongPress(MotionEvent e) {
            if (fragmentAdapter.instantiateItem(pager, pager.getCurrentItem()) instanceof BaseListFragment) {
                ((BaseListFragment) fragmentAdapter.instantiateItem(pager, pager.getCurrentItem())).goToTop();
            }
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (fragmentAdapter.instantiateItem(pager, pager.getCurrentItem()) instanceof BaseListFragment) {
                ((BaseListFragment) fragmentAdapter.instantiateItem(pager, pager.getCurrentItem())).goToTop();
            }
            return true;
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            animateDragged();
            return true;
        }

        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }
    });

    imgBarAvatarBg.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return imgBarAvatarGestureDetector.onTouchEvent(motionEvent);
        }
    });

    refreshTheme();

    reloadBarAvatar();

    refreshActionBarColumns();

    if (goToColumnType >= 0) {
        if ((goToColumnType == TweetTopicsUtils.COLUMN_TIMELINE
                || goToColumnType == TweetTopicsUtils.COLUMN_MENTIONS
                || goToColumnType == TweetTopicsUtils.COLUMN_DIRECT_MESSAGES) && goToColumnUser >= 0) {
            openUserColumn(goToColumnUser, goToColumnType);
        }
        if (goToColumnType == TweetTopicsUtils.COLUMN_SEARCH && goToColumnSearch > 0) {
            openSearchColumn(new Entity("search", goToColumnSearch));
        }
    } else if (goToColumnType == TweetTopicsUtils.COLUMN_MY_ACTIVITY) {
    } else if (goToColumnPosition > 0) {
        goToColumn((int) goToColumnPosition, false, selectedTweetId);
    } else if (positionFromSensor >= 0) {
        goToColumn(positionFromSensor, false, selectedTweetId);
    } else {
        int col = fragmentAdapter.getPositionColumnActive();
        if (col > 0)
            goToColumn(col, false, selectedTweetId);
    }

    // comprobar si hay que proponer ir al market

    int access_count = PreferenceUtils.getApplicationAccessCount(this);

    if (access_count <= 20) {
        if (access_count == 20) {
            try {
                AlertDialog dialog = DialogUtils.RateAppDialogBuilder.create(this);
                dialog.show();
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        }

        PreferenceUtils.setApplicationAccessCount(this, access_count + 1);
    }

    PreferenceUtils.showChangeLog(this, true);

}

From source file:com.abcvoipsip.ui.SipHome.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //prefWrapper = new PreferencesWrapper(this);
    prefProviderWrapper = new PreferencesProviderWrapper(this);

    /*//from www  . j a  va2  s. c o m
     * Resources r; try { r =
     * getPackageManager().getResourcesForApplication("com.etatgere"); int
     * rThemeId = r.getIdentifier("com.etatgere:style/LightTheme", null,
     * null); Log.e(THIS_FILE, "Remote theme " + rThemeId); Theme t =
     * r.newTheme(); t.applyStyle(rThemeId, false); //getTheme().setTo(t); }
     * catch (NameNotFoundException e) { Log.e(THIS_FILE,
     * "Not found app etatgere"); }
     */
    if (USE_LIGHT_THEME) {
        setTheme(R.style.LightTheme_noTopActionBar);
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.sip_home);

    final ActionBar ab = getSupportActionBar();
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // showAbTitle = Compatibility.hasPermanentMenuKey

    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);

    Tab dialerTab = ab.newTab()
            // .setText(R.string.dial_tab_name_text)
            .setIcon(R.drawable.ic_ab_dialer_holo_dark);
    Tab callLogTab = ab.newTab()
            // .setText(R.string.calllog_tab_name_text)
            .setIcon(R.drawable.ic_ab_history_holo_dark);

    Tab favoritesTab = ab.newTab()
            // .setText(R.string.messages_tab_name_text)
            .setIcon(R.drawable.ic_ab_favourites_holo_dark);

    Tab messagingTab = null;
    if (CustomDistribution.supportMessaging()) {
        messagingTab = ab.newTab()
                // .setText(R.string.messages_tab_name_text)
                .setIcon(R.drawable.ic_ab_text_holo_dark);
    }

    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(dialerTab, DialerFragment.class);
    mTabsAdapter.addTab(callLogTab, CallLogListFragment.class);
    mTabsAdapter.addTab(favoritesTab, FavListFragment.class);
    if (messagingTab != null) {
        mTabsAdapter.addTab(messagingTab, ConversationsListFragment.class);
    }

    hasTriedOnceActivateAcc = false;

    if (!prefProviderWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    selectTabWithAction(getIntent());
    Log.setLogLevel(prefProviderWrapper.getLogLevel());

    // Async check
    asyncSanityCheker = new Thread() {
        public void run() {
            asyncSanityCheck();
        };
    };
    asyncSanityCheker.start();
}