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.septrivium.augeo.ui.SipHome.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(getUILConfig().build());
    }/*from w w w  . j  a va  2s . c  om*/
    OpenVpnConfigManager.init(this);
    AuGeoPreferenceManager.init(this);
    ExternalAppDatabase extapps = new ExternalAppDatabase(this);
    extapps.addApp(getPackageName());
    AuGeoServiceFlowManager.getInstance().registerAppFlowCallbackListener(this);
    connectionReciever = new ConnectionReciever();
    connectionReciever = new ConnectionReciever();

    Intent intent = VpnService.prepare(this);
    if (shouldStartAppFlow(intent)) {
        startActivityForResult(intent, ANDROID_VPN_SERVICE_PERMISSION);
        android.util.Log.d("VPN_SERVICE_PREPARE", "SipHome:onCreate()");
    }

    if (intent == null) {
        startAppFlow();
    }
    //prefWrapper = new PreferencesWrapper(this);

    prefProviderWrapper = new PreferencesProviderWrapper(this);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.sip_home);

    this.home = this;
    final ActionBar ab = getSupportActionBar();
    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // showAbTitle = Compatibility.hasPermanentMenuKey

    Tab dialerTab = ab.newTab().setContentDescription(R.string.dial_tab_name_text)
            .setIcon(R.drawable.ic_ab_dialer_holo_dark);
    Tab callLogTab = ab.newTab().setContentDescription(R.string.calllog_tab_name_text)
            .setIcon(R.drawable.ic_ab_history_holo_dark);
    Tab favoritesTab = null;
    if (CustomDistribution.supportFavorites()) {
        favoritesTab = ab.newTab().setContentDescription(R.string.favorites_tab_name_text)
                .setIcon(R.drawable.ic_ab_favourites_holo_dark);
    }
    Tab messagingTab = null;
    if (CustomDistribution.supportMessaging()) {
        messagingTab = ab.newTab().setContentDescription(R.string.messages_tab_name_text)
                .setIcon(R.drawable.ic_ab_text_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);
    if (favoritesTab != null) {
        //            mTabsAdapter.addTab(favoritesTab, FavListFragment.class, TAB_ID_FAVORITES);
    }
    if (messagingTab != null) {
        //            mTabsAdapter.addTab(messagingTab, ConversationsListFragment.class, TAB_ID_MESSAGES);
    }

    hasTriedOnceActivateAcc = false;

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

    selectTabWithAction(getIntent());
    Log.setLogLevel(5);

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

From source file:com.BibleQuote.BibleQuoteAndroid.ui.ReaderActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    if (PreferenceHelper.restoreStateBoolean("DisableAutoScreenRotation")) {
        super.onConfigurationChanged(newConfig);
        this.setRequestedOrientation(Surface.ROTATION_0);
    } else {// www. j  a v  a 2 s  .  com
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        super.onConfigurationChanged(newConfig);
    }
}

From source file:com.skubit.android.SkubitAndroidActivity.java

private void unlockOrientation() {
    Log.d(TAG, "Unlock Orientation");
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}

From source file:com.mschlauch.comfortreader.FullscreenActivity.java

public void menuButtonClicked(View view) {
    if (switchofallmenus == false) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        settingsload.loadRealSettingstoPreferences();
        stop();//www .  ja  va  2s.  co  m
        Intent i = new Intent(this, CRPreferenceActivity.class);
        startActivityForResult(i, 1);
    }
}

From source file:es.rgmf.libresportgps.MainActivity.java

@Override
public void onPostExecute() {
    // Dismiss the dialog progress.
    if (mProgressDialog != null) {
        mProgressDialog.dismiss();/* w w  w.  j  a v  a2s .  c o m*/
    }

    // Load the track list fragment to refresh and load the new track.
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.replace(R.id.container, TrackListFragment.newInstance());
    mFragmentManager.popBackStack();
    transaction.commitAllowingStateLoss();

    // Activate the rotation screen.
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

}

From source file:com.mschlauch.comfortreader.FullscreenActivity.java

public void retreiveSavedOptions() {
    switchofallmenus = true;//from  ww  w.j a  v a 2s  .  co m
    spinner.setVisibility(View.VISIBLE);
    String eins = "";
    new AsyncTask<String, Void, String>() {

        @Override
        protected String doInBackground(String... urlStr) {
            // do stuff on non-UI thread
            settingsload.reloadSelectedBook();

            wordsperminute = settingsload.getWordsPerMinute();
            segmenterObject.minblocksize = settingsload.getMinBlockSize();
            segmenterObject.maxblocksize = settingsload.getMaxBlockSize();
            segmenterObject.textcolor = settingsload.getTextColor();
            segmenterObject.emphasiscolor = settingsload.getFocusColor();
            segmenterObject.backgroundcolor = settingsload.getBackgroundColor();

            segmenterObject.maxcharactersperline = settingsload.getMaxBlockSize();
            segmenterObject.loadPreviewcolorString();

            int actual = settingsload.getGlobalPosition();
            segmenterObject.globalposition = actual;
            segmenterObject.globalpositionbefore = actual;
            //Load Content
            String text = settingsload.getTexttoRead() + "";
            String textdefault = getString(R.string.support_standarttext);
            Log.i("fullscreen", "text  is: " + text);

            segmenterObject.loadTexttoRead(textdefault);
            if (text.equals("standarttext")) {
                segmenterObject.loadTexttoRead(textdefault);
                segmenterObject.globalposition = 0;
                segmenterObject.emphasiscolor = Color.parseColor("#ffee00");
                segmenterObject.textcolor = Color.parseColor("#ffffff");
            } else {
                segmenterObject.loadTexttoRead(text);
            }

            if (text.length() > 16) {

            } else {
                //it is importanted that the default text is already segmentable.

            }
            Log.i("fullscreen 2", " real text  is: " + segmenterObject.texttoread);

            segmenterObject.loadallprehtmls();

            String out = "";
            return out;

        }

        @Override
        protected void onPostExecute(String htmlCode) {
            // do stuff on UI thread with the html

            contentView.setTextSize(settingsload.getFontSize());
            contentView.setBackgroundColor(settingsload.getBackgroundColor());

            String parole = settingsload.getOrientationMode();

            Log.i("Fullscreen", "orientation loading" + parole);
            if (parole.equals("1")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
            } else if (parole.equals("2")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
            } else if (parole.equals("0")) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
            }

            parole = settingsload.getFontName();

            Log.i("Fullscreen", "orientation loading" + parole);
            if (parole.equals("sans")) {
                contentView.setTypeface(Typeface.SANS_SERIF);
            } else if (parole.equals("serif")) {
                contentView.setTypeface(Typeface.SERIF);
            } else if (parole.equals("mono")) {
                contentView.setTypeface(Typeface.MONOSPACE);
            }

            spinner.setVisibility(View.GONE);

            switchofallmenus = false;
            previousButtonClicked(null);
            nextButtonClicked(null);

        }
    }.execute(eins);

    //Line Spacing...
    // contentView.setLineSpacing(0,(float) 1.28);

    //actual = retrieveNumber("maxlinelength");

    //settingsload.adjustGlobalPositionToPercentage(settingsload.getGlobalPositionSeekbarValue());

    //Log.i("fullscreen", "globalposition:" + actual);

    // get the seekbar etc right...

    //   startdialog();

}

From source file:au.gov.ga.worldwind.androidremote.client.Remote.java

public void setLockLandscape(boolean lockLandscape) {
    this.lockLandscape = lockLandscape;
    setRequestedOrientation(/*w  w  w . j  av a2  s  .c  o m*/
            lockLandscape ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR);
}

From source file:org.woltage.irssiconnectbot.ConsoleActivity.java

/**
 *
 *///w w  w.  ja  va  2 s.  c o m
private void configureOrientation() {
    String rotateDefault;
    if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS)
        rotateDefault = PreferenceConstants.ROTATION_PORTRAIT;
    else
        rotateDefault = PreferenceConstants.ROTATION_LANDSCAPE;

    String rotate = prefs.getString(PreferenceConstants.ROTATION, rotateDefault);
    if (PreferenceConstants.ROTATION_DEFAULT.equals(rotate))
        rotate = rotateDefault;

    // request a forced orientation if requested by user
    if (PreferenceConstants.ROTATION_LANDSCAPE.equals(rotate)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        forcedOrientation = true;
    } else if (PreferenceConstants.ROTATION_PORTRAIT.equals(rotate)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        forcedOrientation = true;
    } else if (PreferenceConstants.ROTATION_SENSOR.equals(rotate)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        forcedOrientation = false;
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        forcedOrientation = false;
    }
}

From source file:com.itude.mobile.mobbl.core.controller.MBViewManager.java

public void setOrientation(MBPage page) {

    MBPage.OrientationPermission orientationPermissions = page.getOrientationPermissions();

    /*/*from   ww  w  . j  a v  a  2 s.  c o m*/
     *  If no orientation permissions have been set on a Page level we want to use the permission that is defined in the the AndroidManifest.xml (if any)
     */
    if (orientationPermissions == MBPage.OrientationPermission.UNDEFINED) {
        if (_defaultScreenOrientation != getRequestedOrientation()) {
            setRequestedOrientation(_defaultScreenOrientation);
        }

    } else if (orientationPermissions == MBPage.OrientationPermission.ANY) {
        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_SENSOR) {
            Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to SENSOR");
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        }
    } else if (orientationPermissions == OrientationPermission.PORTRAIT) {
        Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to PORTRAIT");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (orientationPermissions == OrientationPermission.LANDSCAPE) {
        Log.d(Constants.APPLICATION_NAME, "MBViewManager.setOrientation: Changing to LANDSCAPE");
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

}

From source file:com.xmobileapp.rockplayer.RockPlayer.java

/**********************************************
 * //w w  w  . j  a  v  a2 s.  c  o m
 *  Called when the activity is first created
 *  
 **********************************************/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    System.gc();

    //Log.i("PRFMC", "1");
    /*
    * Window Properties
    */
    //requestWindowFeature(Window.FEATURE_PROGRESS);
    //requestWindowFeature(Window.PROGRESS_VISIBILITY_ON);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    /*
     * Blur&Dim the BG
     */
    // Have the system blur any windows behind this one.
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
    //                WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    ////        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, 
    ////              WindowManager.LayoutParams.FLAG_DITHER);
    //        getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, 
    //              WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    //        WindowManager.LayoutParams params = getWindow().getAttributes();
    //        params.dimAmount = 0.625f;
    //        getWindow().setAttributes(params);

    //        Resources.Theme theme = getTheme();
    //        theme.dump(arg0, arg1, arg2)

    //setContentView(R.layout.songfest_main);
    //Log.i("PRFMC", "2");

    /*
     * Initialize Display
     */
    WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    this.display = windowManager.getDefaultDisplay();
    //Log.i("PRFMC", "3");

    /*
     * Set Bug Report Handler
     */
    fdHandler = new FilexDefaultExceptionHandler(this);

    /*
     * Check if Album Art Directory exists
     */
    checkAlbumArtDirectory();
    checkConcertDirectory();
    checkPreferencesDirectory();
    checkBackgroundDirectory();
    //Log.i("PRFMC", "7");

    /*
     * Get Preferences
     */
    readPreferences();

    /*
     * Force landscape or auto-rotate orientation if user requested
     */
    if (alwaysLandscape)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if (autoRotate)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

    /*
      * Create UI and initialize UI vars
      */
    setContentView(R.layout.songfest_main);

    //getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //if (true) return;

    //if(true)
    //   return;
    //Log.i("PRFMC", "4");
    initializeAnimations();
    //Log.i("PRFMC", "5");
    initializeUiVariables();
    //Log.i("PRFMC", "6");

    /*
     * Set Background
     */
    setBackground();

    /*
     * Set Current View
     */
    switch (VIEW_STATE) {
    case LIST_EXPANDED_VIEW:
        setListExpandedView();
        break;
    case FULLSCREEN_VIEW:
        setFullScreenView();
        break;
    default:
        setNormalView();
        break;
    }

    //        AlphaAnimation aAnim = new AlphaAnimation(0.0f, 0.92f);
    //        aAnim.setFillAfter(true);
    //        aAnim.setDuration(200);
    //        mainUIContainer.startAnimation(aAnim);

    /*
     * Check for SD Card
     */
    if (!android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        Dialog noSDDialog = new Dialog(this);
        noSDDialog.setTitle("SD Card Error!");
        noSDDialog.setContentView(R.layout.no_sd_alert_layout);
        noSDDialog.show();
        return;
    }

    /*
     * Get a Content Resolver to browse
     * the phone audio database
     */
    contentResolver = getContentResolver();

    /*
     * Get Preferences
     */
    //SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH);
    settings = new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH);
    // Shuffle
    boolean shuffle = settings.getBoolean("Shuffle", false);
    this.SHUFFLE = shuffle;
    //Playlist
    if (playlist == constants.PLAYLIST_NONE)
        playlist = settings.getLong(constants.PREF_KEY_PLAYLIST, constants.PLAYLIST_ALL);
    Log.i("PLAYLIST PREF", constants.PREF_KEY_PLAYLIST + " " + constants.PLAYLIST_ALL + " " + playlist);

    /*
     * Check if the MediaScanner is scanning
     */
    //        ProgressDialog pD = null;
    //        while(isMediaScannerScanning(this, contentResolver) == true){
    //           if(pD == null){
    //              pD = new ProgressDialog(this);
    //              pD.setTitle("Scanning Media");
    //              pD.setMessage("Wait please...");
    //              pD.show();
    //           }
    //           try {
    //            wait(2000);
    //         } catch (InterruptedException e) {
    //            e.printStackTrace();
    //         }
    //        }
    //        if(pD != null)
    //           pD.dismiss();

    /*
     * Initialize mediaPlayer
     */
    //this.mediaPlayer = new MediaPlayer();
    //this.mediaPlayer.setOnCompletionListener(songCompletedListener);

    /*
     * Initialize (or connect to) BG Service
     *  - when connected it will call the method getCurrentPlaying()
     *     and will cause the Service to reset its albumCursor
     */
    initializeService();
    //Log.i("PRFMC", "8");
    musicChangedIntentReceiver = new MusicChangedIntentReceiver();
    albumChangedIntentReceiver = new AlbumChangedIntentReceiver();
    mediaButtonPauseIntentReceiver = new MediaButtonPauseIntentReceiver();
    mediaButtonPlayIntentReceiver = new MediaButtonPlayIntentReceiver();
    registerReceiver(musicChangedIntentReceiver, musicChangedIntentFilter);
    //Log.i("PRFMC", "9");
    registerReceiver(albumChangedIntentReceiver, albumChangedIntentFilter);
    //Log.i("PRFMC", "10");
    registerReceiver(mediaButtonPauseIntentReceiver, mediaButtonPauseIntentFilter);
    registerReceiver(mediaButtonPlayIntentReceiver, mediaButtonPlayIntentFilter);
    // calls also getCurrentPlaying() upon connection

    /*
     * Register Media Button Receiver
     */
    //        mediaButtonIntentReceiver = new MediaButtonIntentReceiver();
    //        registerReceiver(mediaButtonIntentReceiver, new IntentFilter("android.intent.action.MEDIA_BUTTON"));

    /*
      * Get album information on a new
      * thread
      */
    //new Thread(){
    //   public void run(){
    getAlbums(false);
    //Log.i("PRFMC", "11");
    //   }
    //}.start();

    /*
     * Check for first time run ----------
     * 
     * Save Software Version
     *    &
     * Show Help Screen
     */
    //            if(!settings.contains("Version")){
    //               Editor settingsEditor = settings.edit();
    //               settingsEditor.putLong("Version", VERSION);
    //               settingsEditor.commit();
    //               this.hideMainUI();
    //               this.showHelpUI();
    //            }
    Log.i("DBG", "Version - " + (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0)
            + " - " + VERSION);
    if (!(new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).contains("Version")
            || (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).getLong("Version", 0) < VERSION) {

        (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH)).putLong("Version", VERSION);

        /*
        * Clear previous Album Art
        */
        Builder aD = new AlertDialog.Builder(context);
        aD.setTitle("New Version");
        aD.setMessage(
                "The new version of RockOn supports album art download from higher quality sources. Do you want to download art now? "
                        + "Every 10 albums will take aproximately 1 minute to download. "
                        + "(You can always do this later by choosing the 'Get Art' menu option)");
        aD.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                //(new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).putLong("artImportDate", 0);
                try {
                    File albumArtDir = new File(FILEX_ALBUM_ART_PATH);
                    String[] fileList = albumArtDir.list();
                    File albumArtFile;
                    for (int i = 0; i < fileList.length; i++) {
                        albumArtFile = new File(albumArtDir.getAbsolutePath() + "/" + fileList[i]);
                        albumArtFile.delete();
                    }
                    checkAlbumArtDirectory();
                    triggerAlbumArtFetching();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        });
        aD.setNegativeButton("No", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }

        });
        aD.show();

        /*
        * Version 2 specific default preference changes
        */
        // version 2 specific
        if (albumCursor.getCount() > 100)
            (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH))
                    .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, false);
        else
            (new RockOnPreferenceManager(this.FILEX_PREFERENCES_PATH))
                    .putBoolean(PREFS_SHOW_ART_WHILE_SCROLLING, true);

        readPreferences();
        albumAdapter.showArtWhileScrolling = showArtWhileScrolling;
        albumAdapter.showFrame = showFrame;
        //

        /*
        * Show help screen
        */
        this.hideMainUI();
        this.showHelpUI();
    } else {
        /*
         * Run albumArt getter in background
         */
        long lastAlbumArtImportDate = settings.getLong("artImportDate", 0);
        Log.i("SYNCTIME",
                lastAlbumArtImportDate + " + " + this.ART_IMPORT_INTVL + " < " + System.currentTimeMillis());
        if (lastAlbumArtImportDate + this.ART_IMPORT_INTVL < System.currentTimeMillis()) {
            triggerAlbumArtFetching();
        }
        //Log.i("PRFMC", "13");
    }
}