Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:org.linphone.CallIncomingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*  w  ww  . java 2  s  .c  om*/

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.call_incoming);

    name = (TextView) findViewById(R.id.contact_name);
    number = (TextView) findViewById(R.id.contact_number);
    contactPicture = (ImageView) findViewById(R.id.contact_picture);

    // set this flag so this activity will stay in front of the keyguard
    int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
    getWindow().addFlags(flags);

    final int screenWidth = getResources().getDisplayMetrics().widthPixels;

    acceptUnlock = (LinearLayout) findViewById(R.id.acceptUnlock);
    declineUnlock = (LinearLayout) findViewById(R.id.declineUnlock);

    accept = (ImageView) findViewById(R.id.accept);
    decline = (ImageView) findViewById(R.id.decline);
    accept.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            decline.setVisibility(View.GONE);
            acceptUnlock.setVisibility(View.VISIBLE);

        }
    });

    accept.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            float curX;
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
                acceptUnlock.setVisibility(View.VISIBLE);
                decline.setVisibility(View.GONE);
                answerX = motionEvent.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                curX = motionEvent.getX();
                if ((answerX - curX) >= 0)
                    view.scrollBy((int) (answerX - curX), view.getScrollY());
                answerX = curX;
                if (curX < screenWidth / 4) {
                    answer();
                    return true;
                }
                break;
            case MotionEvent.ACTION_UP:
                view.scrollTo(0, view.getScrollY());
                decline.setVisibility(View.VISIBLE);
                acceptUnlock.setVisibility(View.GONE);
                break;
            }
            return true;
        }
    });

    decline.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            float curX;
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
                declineUnlock.setVisibility(View.VISIBLE);
                accept.setVisibility(View.GONE);
                declineX = motionEvent.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                curX = motionEvent.getX();
                view.scrollBy((int) (declineX - curX), view.getScrollY());
                declineX = curX;
                Log.w(curX);
                if (curX > (screenWidth / 2)) {
                    decline();
                    return true;
                }
                break;
            case MotionEvent.ACTION_UP:
                view.scrollTo(0, view.getScrollY());
                accept.setVisibility(View.VISIBLE);
                declineUnlock.setVisibility(View.GONE);
                break;

            }
            return true;
        }
    });

    decline.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            accept.setVisibility(View.GONE);
            acceptUnlock.setVisibility(View.VISIBLE);
        }
    });

    mListener = new LinphoneCoreListenerBase() {
        @Override
        public void callState(LinphoneCore lc, LinphoneCall call, State state, String message) {
            if (call == mCall && State.CallEnd == state) {
                finish();
            }
            if (state == State.StreamsRunning) {
                Log.e("CallIncommingActivity - onCreate -  State.StreamsRunning - speaker = "
                        + LinphoneManager.getLc().isSpeakerEnabled());
                // The following should not be needed except some devices need it (e.g. Galaxy S).
                LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
            }
        }
    };

    // super.onCreate(savedInstanceState);
    instance = this;
}

From source file:net.yoik.cordova.plugins.screenorientation.YoikScreenOrientation.java

private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {

    String action = args.optString(0);

    if (action.equals("set")) {

        String orientation = args.optString(1);

        Log.d(TAG, "Requested ScreenOrientation: " + orientation);

        Activity activity = cordova.getActivity();

        if (orientation.equals(UNLOCKED)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else if (orientation.equals(LANDSCAPE_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_PRIMARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
        } else if (orientation.equals(LANDSCAPE_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        } else if (orientation.equals(PORTRAIT_SECONDARY)) {
            activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }//from  w w w.  ja  v  a  2 s .com

        callbackContext.success();
        return true;

    } else {
        callbackContext.error("ScreenOrientation not recognised");
        return false;
    }
}

From source file:com.gsma.rcs.ri.messaging.GroupDeliveryInfoList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set layout
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.delivery_info_list);
    mMessageId = getIntent().getStringExtra(EXTRA_MESSAGE_ID);
    // Initialize the adapter.
    mAdapter = new GroupDeliveryInfoCursorAdapter(this);

    // Associate the list adapter with the ListView.
    ListView listView = (ListView) findViewById(android.R.id.list);
    listView.setAdapter(mAdapter);//from  w w w  .ja v  a2 s . co  m
    // Initialize the Loader with id and callbacks 'mCallbacks'.
    getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    if (LogUtils.isActive) {
        Log.d(LOGTAG, "onCreate");
    }
}

From source file:com.manning.androidhacks.hack029.MainActivity.java

public void enforcePortrait() {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}

From source file:com.radiusnetworks.museumguide.MuseumItemsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_museum_items);
    application = (MuseumGuideApplication) this.getApplication();

    application.setMuseumItemsActivity(this);

    if (this.getIntent().getExtras() != null) {
        currentItemId = this.getIntent().getExtras().getString("item_id");
    } else {//from  w  w  w.j a  v  a2s  .  co m
        // By default, show the very first item in the museum, unless told to do otherwise
        currentItemId = application.getMuseum().getItemList().get(0).getId();
    }
    viewPager = (ViewPager) findViewById(R.id.pager);
    museumControls = new MuseumControls(findViewById(R.id.activity_museum_items));
    findViewById(R.id.search_dialog).setVisibility(View.INVISIBLE);

    setAutomaticMode();
    hideNextItemNotification();
    Log.d(TAG, "Museum at startup:");
    for (MuseumItem item : application.getMuseum().getItemList()) {
        Log.d(TAG, "Item id " + item.getId() + " has title: " + item.getTitle());
    }
}

From source file:com.b44t.ui.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_MessengerProj);
    super.onCreate(savedInstanceState);
    Theme.loadRecources(this);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (AndroidUtilities.isTablet()) {
        setContentView(R.layout.intro_layout_tablet);
    } else {/*  ww w  . j  a  v  a 2  s .  c  o m*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
        icons = new int[] { R.drawable.intro7, R.drawable.intro6, R.drawable.intro5, R.drawable.intro4,
                R.drawable.intro3, R.drawable.intro2, R.drawable.intro1 };
        titles = new int[] { R.string.Intro7Headline, R.string.Intro6Headline, R.string.Intro5Headline,
                R.string.Intro4Headline, R.string.Intro3Headline, R.string.Intro2Headline,
                R.string.Intro1Headline };
        messages = new int[] { R.string.Intro7Message, R.string.Intro6Message, R.string.Intro5Message,
                R.string.Intro4Message, R.string.Intro3Message, R.string.Intro2Message,
                R.string.Intro1Message };
    } else {
        icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4,
                R.drawable.intro5, R.drawable.intro6, R.drawable.intro7 };
        titles = new int[] { R.string.Intro1Headline, R.string.Intro2Headline, R.string.Intro3Headline,
                R.string.Intro4Headline, R.string.Intro5Headline, R.string.Intro6Headline,
                R.string.Intro7Headline };
        messages = new int[] { R.string.Intro1Message, R.string.Intro2Message, R.string.Intro3Message,
                R.string.Intro4Message, R.string.Intro5Message, R.string.Intro6Message,
                R.string.Intro7Message };
    }
    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    startMessagingButton.setText(ApplicationLoader.applicationContext.getString(R.string.IntroStartMessaging)
            .toUpperCase(Locale.getDefault()));
    if (Build.VERSION.SDK_INT >= 21) {
        StateListAnimator animator = new StateListAnimator();
        animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4))
                .setDuration(200));
        animator.addState(new int[] {}, ObjectAnimator
                .ofFloat(startMessagingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2))
                .setDuration(200));
        startMessagingButton.setStateListAnimator(animator);
    }
    topImage1 = (ImageView) findViewById(R.id.icon_image1);
    topImage2 = (ImageView) findViewById(R.id.icon_image2);
    bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
    topImage2.setVisibility(View.GONE);
    viewPager.setAdapter(new IntroAdapter());
    viewPager.setPageMargin(0);
    viewPager.setOffscreenPageLimit(1);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int i) {

        }

        @Override
        public void onPageScrollStateChanged(int i) {
            if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
                if (lastPage != viewPager.getCurrentItem()) {
                    lastPage = viewPager.getCurrentItem();

                    final ImageView fadeoutImage;
                    final ImageView fadeinImage;
                    if (topImage1.getVisibility() == View.VISIBLE) {
                        fadeoutImage = topImage1;
                        fadeinImage = topImage2;

                    } else {
                        fadeoutImage = topImage2;
                        fadeinImage = topImage1;
                    }

                    fadeinImage.bringToFront();
                    fadeinImage.setImageResource(icons[lastPage]);
                    fadeinImage.clearAnimation();
                    fadeoutImage.clearAnimation();

                    Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_out);
                    outAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            fadeoutImage.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_in);
                    inAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                            fadeinImage.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    fadeoutImage.startAnimation(outAnimation);
                    fadeinImage.startAnimation(inAnimation);
                }
            }
        }
    });

    startMessagingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (startPressed) {
                return;
            }
            startPressed = true;
            Intent intent2 = new Intent(IntroActivity.this, LaunchActivity.class);
            intent2.putExtra("fromIntro", true);
            startActivity(intent2);
            finish();
        }
    });

    justCreated = true;
}

From source file:co.taqat.call.CallIncomingActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//from   w w w. j  a v a 2 s  . c o  m

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.call_incoming);

    name = (TextView) findViewById(R.id.contact_name);
    number = (TextView) findViewById(R.id.contact_number);
    contactPicture = (ImageView) findViewById(R.id.contact_picture);

    // set this flag so this activity will stay in front of the keyguard
    int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
    getWindow().addFlags(flags);

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

    final int screenWidth = getResources().getDisplayMetrics().widthPixels;

    acceptUnlock = (LinearLayout) findViewById(R.id.acceptUnlock);
    declineUnlock = (LinearLayout) findViewById(R.id.declineUnlock);

    accept = (ImageView) findViewById(R.id.accept);
    decline = (ImageView) findViewById(R.id.decline);
    accept.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            decline.setVisibility(View.GONE);
            acceptUnlock.setVisibility(View.VISIBLE);

        }
    });

    accept.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            float curX;
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
                acceptUnlock.setVisibility(View.VISIBLE);
                decline.setVisibility(View.GONE);
                answerX = motionEvent.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                curX = motionEvent.getX();
                if ((answerX - curX) >= 0)
                    view.scrollBy((int) (answerX - curX), view.getScrollY());
                answerX = curX;
                if (curX < screenWidth / 4) {
                    answer();
                    return true;
                }
                break;
            case MotionEvent.ACTION_UP:
                view.scrollTo(0, view.getScrollY());
                decline.setVisibility(View.VISIBLE);
                acceptUnlock.setVisibility(View.GONE);
                break;
            }
            return true;
        }
    });

    decline.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            float curX;
            switch (motionEvent.getAction()) {
            case MotionEvent.ACTION_DOWN:
                declineUnlock.setVisibility(View.VISIBLE);
                accept.setVisibility(View.GONE);
                declineX = motionEvent.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                curX = motionEvent.getX();
                view.scrollBy((int) (declineX - curX), view.getScrollY());
                declineX = curX;
                Log.w(curX);
                if (curX > (screenWidth / 2)) {
                    decline();
                    return true;
                }
                break;
            case MotionEvent.ACTION_UP:
                view.scrollTo(0, view.getScrollY());
                accept.setVisibility(View.VISIBLE);
                declineUnlock.setVisibility(View.GONE);
                break;

            }
            return true;
        }
    });

    decline.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            accept.setVisibility(View.GONE);
            acceptUnlock.setVisibility(View.VISIBLE);
        }
    });

    mListener = new LinphoneCoreListenerBase() {
        @Override
        public void callState(LinphoneCore lc, LinphoneCall call, State state, String message) {
            if (call == mCall && State.CallEnd == state) {
                finish();
            }
            if (state == State.StreamsRunning) {
                // The following should not be needed except some devices need it (e.g. Galaxy S).
                LinphoneManager.getLc().enableSpeaker(LinphoneManager.getLc().isSpeakerEnabled());
            }
        }
    };

    super.onCreate(savedInstanceState);
    instance = this;
}

From source file:br.org.funcate.dynamicforms.FormActivity.java

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // make sure the orientation can't be changed once this activity started
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {//w ww.  jav a  2  s .co m
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        sectionName = extras.getString(LibraryConstants.PREFS_KEY_FORM_NAME);
        sectionObjectString = extras.getString(LibraryConstants.PREFS_KEY_FORM_JSON);
        latitude = extras.getDouble(LibraryConstants.LATITUDE);
        longitude = extras.getDouble(LibraryConstants.LONGITUDE);
        elevation = extras.getDouble(LibraryConstants.ELEVATION);
        noteId = extras.getLong(LibraryConstants.SELECTED_POINT_ID);
    }

    try {
        if (sectionObjectString == null) {
            sectionObject = TagsManager.getInstance(this).getSectionByName(sectionName);
            // copy the section object, which will be kept around along the activity
            sectionObjectString = sectionObject.toString();
        }

        sectionObject = new JSONObject(sectionObjectString);
        formNames4Section = TagsManager.getFormNames4Section(sectionObject);
    } catch (Exception e) {
        Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
    setContentView(R.layout.form);

}

From source file:cz.babi.android.remoteme.ui.ActivityDialogListOfRemoteControllers.java

/**
 * Set orientation./*from www  . j  a va 2  s .co m*/
 */
private void setOrientation() {
    String currentOrientationLock = PreferenceManager.getDefaultSharedPreferences(this)
            .getString(getString(R.string.pref_name_orientation_lock), getString(R.string.pref_value_default));

    if (currentOrientationLock.equals(getString(R.string.pref_value_portait))) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (currentOrientationLock.equals(getString(R.string.pref_value_landscape))) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:com.rvl.android.getnzb.GetNZB.java

/** Called when the activity is first created. */
@Override/*from ww w  . jav a 2 s  .co  m*/
public void onCreate(Bundle savedInstanceState) {
    Log.d(Tags.LOG, "------ STARTING GETNZB ------");
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.login);
    preferences = getSharedPreferences(Tags.PREFS, 0);
    builder = new AlertDialog.Builder(this);

}