Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_UNSPECIFIED

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_UNSPECIFIED

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

Click Source Link

Document

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

Usage

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionLivestreamActivity.java

/**
 * Applies YouTube player full screen flags plus forces portrait orientation on small screens
 * when presentation (secondary display) is enabled (as the full screen layout won't have
 * anything to display when an external display is connected).
 *
 * @param usePresentationMode Whether or not to use presentation mode. This is used when an
 *                            external display is connected and the user toggles between
 *                            presentation mode.
 *//*from w w w. j a  v a 2 s . c o m*/
private void setFullscreenFlags(boolean usePresentationMode) {
    if (mYouTubePlayer != null) {
        if (usePresentationMode && mPresentation != null && !mIsTablet) {
            mYouTubePlayer.setFullscreenControlFlags(0);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            mYouTubePlayer.setFullscreenControlFlags(mYouTubeFullscreenFlags);
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }
    }
}

From source file:com.vonglasow.michael.satstat.MainActivity.java

/**
 * Called when a sensor's reading changes. Updates sensor display.
 *//*  w  w w.j av a  2s. c  o m*/
public void onSensorChanged(SensorEvent event) {
    //to enforce sensor rate
    boolean isRateElapsed = false;

    switch (event.sensor.getType()) {
    case Sensor.TYPE_ACCELEROMETER:
        isRateElapsed = (event.timestamp / 1000) - mAccLast >= iSensorRate;
        // if Z acceleration is greater than X/Y combined, lock rotation, else unlock
        if (Math.pow(event.values[2], 2) > Math.pow(event.values[0], 2) + Math.pow(event.values[1], 2)) {
            // workaround (SCREEN_ORIENTATION_LOCK is unsupported on API < 18)
            if (isWideScreen)
                setRequestedOrientation(
                        OR_FROM_ROT_WIDE[this.getWindowManager().getDefaultDisplay().getRotation()]);
            else
                setRequestedOrientation(
                        OR_FROM_ROT_TALL[this.getWindowManager().getDefaultDisplay().getRotation()]);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }
        break;
    case Sensor.TYPE_ORIENTATION:
        isRateElapsed = (event.timestamp / 1000) - mOrLast >= iSensorRate;
        break;
    case Sensor.TYPE_GYROSCOPE:
        isRateElapsed = (event.timestamp / 1000) - mGyroLast >= iSensorRate;
        break;
    case Sensor.TYPE_MAGNETIC_FIELD:
        isRateElapsed = (event.timestamp / 1000) - mMagLast >= iSensorRate;
        break;
    case Sensor.TYPE_LIGHT:
        isRateElapsed = (event.timestamp / 1000) - mLightLast >= iSensorRate;
        break;
    case Sensor.TYPE_PROXIMITY:
        isRateElapsed = (event.timestamp / 1000) - mProximityLast >= iSensorRate;
        break;
    case Sensor.TYPE_PRESSURE:
        isRateElapsed = (event.timestamp / 1000) - mPressureLast >= iSensorRate;
        break;
    case Sensor.TYPE_RELATIVE_HUMIDITY:
        isRateElapsed = (event.timestamp / 1000) - mHumidityLast >= iSensorRate;
        break;
    case Sensor.TYPE_AMBIENT_TEMPERATURE:
        isRateElapsed = (event.timestamp / 1000) - mTempLast >= iSensorRate;
        break;
    }

    if (isSensorViewReady && isRateElapsed) {
        switch (event.sensor.getType()) {
        case Sensor.TYPE_ACCELEROMETER:
            mAccLast = event.timestamp / 1000;
            accX.setText(String.format("%." + mAccSensorRes + "f", event.values[0]));
            accY.setText(String.format("%." + mAccSensorRes + "f", event.values[1]));
            accZ.setText(String.format("%." + mAccSensorRes + "f", event.values[2]));
            accTotal.setText(String.format("%." + mAccSensorRes + "f", Math.sqrt(Math.pow(event.values[0], 2)
                    + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2))));
            accStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_ORIENTATION:
            mOrLast = event.timestamp / 1000;
            orAzimuth.setText(String.format("%.0f%s", event.values[0], getString(R.string.unit_degree)));
            orAziText.setText(formatOrientation(event.values[0]));
            orPitch.setText(String.format("%.0f%s", event.values[1], getString(R.string.unit_degree)));
            orRoll.setText(String.format("%.0f%s", event.values[2], getString(R.string.unit_degree)));
            orStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_GYROSCOPE:
            mGyroLast = event.timestamp / 1000;
            rotX.setText(String.format("%." + mGyroSensorRes + "f", event.values[0]));
            rotY.setText(String.format("%." + mGyroSensorRes + "f", event.values[1]));
            rotZ.setText(String.format("%." + mGyroSensorRes + "f", event.values[2]));
            rotTotal.setText(String.format("%." + mGyroSensorRes + "f", Math.sqrt(Math.pow(event.values[0], 2)
                    + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2))));
            rotStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_MAGNETIC_FIELD:
            mMagLast = event.timestamp / 1000;
            magX.setText(String.format("%." + mMagSensorRes + "f", event.values[0]));
            magY.setText(String.format("%." + mMagSensorRes + "f", event.values[1]));
            magZ.setText(String.format("%." + mMagSensorRes + "f", event.values[2]));
            magTotal.setText(String.format("%." + mMagSensorRes + "f", Math.sqrt(Math.pow(event.values[0], 2)
                    + Math.pow(event.values[1], 2) + Math.pow(event.values[2], 2))));
            magStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_LIGHT:
            mLightLast = event.timestamp / 1000;
            light.setText(String.format("%." + mLightSensorRes + "f", event.values[0]));
            lightStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_PROXIMITY:
            mProximityLast = event.timestamp / 1000;
            proximity.setText(String.format("%." + mProximitySensorRes + "f", event.values[0]));
            proximityStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_PRESSURE:
            mPressureLast = event.timestamp / 1000;
            metPressure.setText(String.format("%." + mPressureSensorRes + "f", event.values[0]));
            pressureStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_RELATIVE_HUMIDITY:
            mHumidityLast = event.timestamp / 1000;
            metHumid.setText(String.format("%." + mHumiditySensorRes + "f", event.values[0]));
            humidStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        case Sensor.TYPE_AMBIENT_TEMPERATURE:
            mTempLast = event.timestamp / 1000;
            metTemp.setText(String.format("%." + mTempSensorRes + "f", event.values[0]));
            tempStatus.setTextColor(getResources().getColor(accuracyToColor(event.accuracy)));
            break;
        }
    }
    if (isGpsViewReady && isRateElapsed) {
        switch (event.sensor.getType()) {
        case Sensor.TYPE_ORIENTATION:
            gpsStatusView.setYaw(event.values[0]);
            break;
        }
    }
}

From source file:com.android.leanlauncher.LauncherTransitionable.java

public void unlockScreenOrientation(boolean immediate) {
    if (Utilities.isRotationEnabled(this)) {
        if (immediate) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {/*from w w w  . j a v a 2s  .  c om*/
            int restoreScreenOrientationDelay = 500;
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                }
            }, restoreScreenOrientationDelay);
        }
    } else {
        lockScreenOrientation(mLastOrientation);
    }
}

From source file:android.content.pm.PackageParser.java

private Activity parseActivity(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs,
        int flags, String[] outError, boolean receiver, boolean hardwareAccelerated)
        throws XmlPullParserException, IOException {
    TypedArray sa = res.obtainAttributes(attrs, R.styleable.AndroidManifestActivity);

    if (mParseActivityArgs == null) {
        mParseActivityArgs = new ParseComponentArgs(owner, outError, R.styleable.AndroidManifestActivity_name,
                R.styleable.AndroidManifestActivity_label, R.styleable.AndroidManifestActivity_icon,
                R.styleable.AndroidManifestActivity_logo, R.styleable.AndroidManifestActivity_banner,
                mSeparateProcesses, R.styleable.AndroidManifestActivity_process,
                R.styleable.AndroidManifestActivity_description, R.styleable.AndroidManifestActivity_enabled);
    }//from  w w w .  jav  a  2  s  . com

    mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>";
    mParseActivityArgs.sa = sa;
    mParseActivityArgs.flags = flags;

    Activity a = new Activity(mParseActivityArgs, new ActivityInfo());
    if (outError[0] != null) {
        sa.recycle();
        return null;
    }

    boolean setExported = sa.hasValue(R.styleable.AndroidManifestActivity_exported);
    if (setExported) {
        a.info.exported = sa.getBoolean(R.styleable.AndroidManifestActivity_exported, false);
    }

    a.info.theme = sa.getResourceId(R.styleable.AndroidManifestActivity_theme, 0);

    a.info.uiOptions = sa.getInt(R.styleable.AndroidManifestActivity_uiOptions,
            a.info.applicationInfo.uiOptions);

    String parentName = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_parentActivityName,
            Configuration.NATIVE_CONFIG_VERSION);
    if (parentName != null) {
        String parentClassName = buildClassName(a.info.packageName, parentName, outError);
        if (outError[0] == null) {
            a.info.parentActivityName = parentClassName;
        } else {
            Log.e(TAG, "Activity " + a.info.name + " specified invalid parentActivityName " + parentName);
            outError[0] = null;
        }
    }

    String str;
    str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_permission, 0);
    if (str == null) {
        a.info.permission = owner.applicationInfo.permission;
    } else {
        a.info.permission = str.length() > 0 ? str.toString().intern() : null;
    }

    str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_taskAffinity,
            Configuration.NATIVE_CONFIG_VERSION);
    a.info.taskAffinity = buildTaskAffinityName(owner.applicationInfo.packageName,
            owner.applicationInfo.taskAffinity, str, outError);

    a.info.flags = 0;
    if (sa.getBoolean(R.styleable.AndroidManifestActivity_multiprocess, false)) {
        a.info.flags |= ActivityInfo.FLAG_MULTIPROCESS;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnTaskLaunch, false)) {
        a.info.flags |= ActivityInfo.FLAG_FINISH_ON_TASK_LAUNCH;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_clearTaskOnLaunch, false)) {
        a.info.flags |= ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_noHistory, false)) {
        a.info.flags |= ActivityInfo.FLAG_NO_HISTORY;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_alwaysRetainTaskState, false)) {
        a.info.flags |= ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_stateNotNeeded, false)) {
        a.info.flags |= ActivityInfo.FLAG_STATE_NOT_NEEDED;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_excludeFromRecents, false)) {
        a.info.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowTaskReparenting,
            (owner.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING) != 0)) {
        a.info.flags |= ActivityInfo.FLAG_ALLOW_TASK_REPARENTING;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnCloseSystemDialogs, false)) {
        a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_showOnLockScreen, false)
            || sa.getBoolean(R.styleable.AndroidManifestActivity_showForAllUsers, false)) {
        a.info.flags |= ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_immersive, false)) {
        a.info.flags |= ActivityInfo.FLAG_IMMERSIVE;
    }

    if (sa.getBoolean(R.styleable.AndroidManifestActivity_primaryUserOnly, false)) {
        a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY;
    }

    if (!receiver) {
        if (sa.getBoolean(R.styleable.AndroidManifestActivity_hardwareAccelerated, hardwareAccelerated)) {
            a.info.flags |= ActivityInfo.FLAG_HARDWARE_ACCELERATED;
        }

        a.info.launchMode = sa.getInt(R.styleable.AndroidManifestActivity_launchMode,
                ActivityInfo.LAUNCH_MULTIPLE);
        a.info.documentLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_documentLaunchMode,
                ActivityInfo.DOCUMENT_LAUNCH_NONE);
        a.info.maxRecents = sa.getInt(R.styleable.AndroidManifestActivity_maxRecents,
                ActivityManager.getDefaultAppRecentsLimitStatic());
        a.info.configChanges = sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0);
        a.info.softInputMode = sa.getInt(R.styleable.AndroidManifestActivity_windowSoftInputMode, 0);

        a.info.persistableMode = sa.getInteger(R.styleable.AndroidManifestActivity_persistableMode,
                ActivityInfo.PERSIST_ROOT_ONLY);

        if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowEmbedded, false)) {
            a.info.flags |= ActivityInfo.FLAG_ALLOW_EMBEDDED;
        }

        if (sa.getBoolean(R.styleable.AndroidManifestActivity_autoRemoveFromRecents, false)) {
            a.info.flags |= ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS;
        }

        if (sa.getBoolean(R.styleable.AndroidManifestActivity_relinquishTaskIdentity, false)) {
            a.info.flags |= ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY;
        }

        if (sa.getBoolean(R.styleable.AndroidManifestActivity_resumeWhilePausing, false)) {
            a.info.flags |= ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
        }

        a.info.resizeable = sa.getBoolean(R.styleable.AndroidManifestActivity_resizeableActivity, false);
        if (a.info.resizeable) {
            // Fixed screen orientation isn't supported with resizeable activities.
            a.info.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        } else {
            a.info.screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation,
                    ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }

        a.info.lockTaskLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0);
    } else {
        a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE;
        a.info.configChanges = 0;

        if (sa.getBoolean(R.styleable.AndroidManifestActivity_singleUser, false)) {
            a.info.flags |= ActivityInfo.FLAG_SINGLE_USER;
            if (a.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) {
                Slog.w(TAG, "Activity exported request ignored due to singleUser: " + a.className + " at "
                        + mArchiveSourcePath + " " + parser.getPositionDescription());
                a.info.exported = false;
                setExported = true;
            }
        }
    }

    sa.recycle();

    if (receiver && (owner.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
        // A heavy-weight application can not have receives in its main process
        // We can do direct compare because we intern all strings.
        if (a.info.processName == owner.packageName) {
            outError[0] = "Heavy-weight applications can not have receivers in main process";
        }
    }

    if (outError[0] != null) {
        return null;
    }

    int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }

        if (parser.getName().equals("intent-filter")) {
            ActivityIntentInfo intent = new ActivityIntentInfo(a);
            if (!parseIntent(res, parser, attrs, true, true, intent, outError)) {
                return null;
            }
            if (intent.countActions() == 0) {
                Slog.w(TAG, "No actions in intent filter at " + mArchiveSourcePath + " "
                        + parser.getPositionDescription());
            } else {
                a.intents.add(intent);
            }
        } else if (!receiver && parser.getName().equals("preferred")) {
            ActivityIntentInfo intent = new ActivityIntentInfo(a);
            if (!parseIntent(res, parser, attrs, false, false, intent, outError)) {
                return null;
            }
            if (intent.countActions() == 0) {
                Slog.w(TAG, "No actions in preferred at " + mArchiveSourcePath + " "
                        + parser.getPositionDescription());
            } else {
                if (owner.preferredActivityFilters == null) {
                    owner.preferredActivityFilters = new ArrayList<ActivityIntentInfo>();
                }
                owner.preferredActivityFilters.add(intent);
            }
        } else if (parser.getName().equals("meta-data")) {
            if ((a.metaData = parseMetaData(res, parser, attrs, a.metaData, outError)) == null) {
                return null;
            }
        } else {
            if (!RIGID_PARSER) {
                Slog.w(TAG, "Problem in package " + mArchiveSourcePath + ":");
                if (receiver) {
                    Slog.w(TAG, "Unknown element under <receiver>: " + parser.getName() + " at "
                            + mArchiveSourcePath + " " + parser.getPositionDescription());
                } else {
                    Slog.w(TAG, "Unknown element under <activity>: " + parser.getName() + " at "
                            + mArchiveSourcePath + " " + parser.getPositionDescription());
                }
                XmlUtils.skipCurrentTag(parser);
                continue;
            } else {
                if (receiver) {
                    outError[0] = "Bad element under <receiver>: " + parser.getName();
                } else {
                    outError[0] = "Bad element under <activity>: " + parser.getName();
                }
                return null;
            }
        }
    }

    if (!setExported) {
        a.info.exported = a.intents.size() > 0;
    }

    return a;
}

From source file:com.android.launcher2.Launcher.java

public void unlockScreenOrientation(boolean immediate) {
    if (isRotationEnabled()) {
        if (immediate) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {//  w  w  w . j  a va2 s. c  o m
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                }
            }, mRestoreScreenOrientationDelay);
        }
    }
}

From source file:com.klinker.android.launcher.launcher3.Launcher.java

public void unlockScreenOrientation(boolean immediate) {
    if (mRotationEnabled) {
        if (immediate) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {//from  w  w  w .j a v a 2 s. c o m
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                }
            }, mRestoreScreenOrientationDelay);
        }
    }
}

From source file:com.android.launcher3.Launcher.java

public void unlockScreenOrientation(boolean immediate) {
    if (mRotationEnabled) {
        if (immediate) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {//  ww w  . j a  v a  2  s. c om
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                }
            }, RESTORE_SCREEN_ORIENTATION_DELAY);
        }
    }
}

From source file:android.app.Activity.java

/**
 * Return the current requested orientation of the activity.  This will
 * either be the orientation requested in its component's manifest, or
 * the last requested orientation given to
 * {@link #setRequestedOrientation(int)}.
 * //from w  w  w  . j a v  a 2 s  .c  o  m
 * @return Returns an orientation constant as used in
 * {@link ActivityInfo#screenOrientation ActivityInfo.screenOrientation}.
 */
public int getRequestedOrientation() {
    if (mParent == null) {
        try {
            return ActivityManagerNative.getDefault().getRequestedOrientation(mToken);
        } catch (RemoteException e) {
            // Empty
        }
    } else {
        return mParent.getRequestedOrientation();
    }
    return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}

From source file:g7.bluesky.launcher3.Launcher.java

public void unlockScreenOrientation(boolean immediate) {
    if (Utilities.isRotationEnabled(this)) {
        if (immediate) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {//from  ww w.j  av a  2s  .  c  o m
            mHandler.postDelayed(new Runnable() {
                public void run() {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
                }
            }, mRestoreScreenOrientationDelay);
        }
    }
}