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:com.tafayor.selfcamerashot.camera.CameraActivity.java

@Override
protected void onCreate(Bundle savedInstanceState)
{

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setTheme(R.style.AppTheme_Light_CameraPreview);

    super.onCreate(savedInstanceState);



    mContext = getApplicationContext();//from  www. ja  va  2 s . c  o  m

   init();

}

From source file:csic.ceab.movelab.beepath.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.webview);/*from  w  w  w  .  j  av a  2s.co m*/

    myWebView = (WebView) findViewById(R.id.webview);

    myWebView.getSettings().setSupportMultipleWindows(true);

    myWebView.getSettings().setPluginsEnabled(true);

    myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.loadDataWithBaseURL("file:///android_asset/", "jquery-1.9.1.min.js", "text/html", "UTF-8", null);

    // myWebView.setWebChromeClient(new WebChromeClient());

    myWebView.loadUrl(BP_URL);

    // adding the interface
    myWebView.addJavascriptInterface(new WebAppInterface(this), "BeePathAndroid");

    myWebView.setWebChromeClient(new MyJavaScriptChromeClient());

    PropertyHolder.init(context);

    myWebView.loadUrl("javascript:setAndroid();");

    // FOR TESTING ONLY I AM CALLING START HERE
    // startFunction("h", "h");

    tv = (TextView) findViewById(R.id.locDisplay);
}

From source file:com.conduit.plastic.common.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);
    initTitleBar();/*from w  ww.  j  a  va2 s  .  c o m*/
    setContentLayout();
    ButterKnife.bind(this);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    // ?activityActivity
    ActivityUtils.addActivity(this);
    initView();
    mCalendar = Calendar.getInstance();
    mYear = mCalendar.get(Calendar.YEAR);
    mMonth = mCalendar.get(Calendar.MONTH) + 1;
    mDay = mCalendar.get(Calendar.DAY_OF_MONTH);
}

From source file:im.ene.lab.toro.sample.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(getResources().getBoolean(R.bool.is_large_screen) ? //
            ActivityInfo.SCREEN_ORIENTATION_USER : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  ww  w  .j  av a 2s .  co  m

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    int lastSelected = ToroSampleApp.pref().getInt(PREF_KEY_STRATEGY, 0);
    Toro.setStrategy(mStrategies.get(lastSelected));
}

From source file:org.xwalk.runtime.extension.api.screenorientation.ScreenOrientationExtension.java

@Override
public void onMessage(int instanceId, String message) {
    String value = getValueString(message, JS_VALUE_TYPE);
    if (value.isEmpty())
        return;//from   w  ww.  j a  v  a  2s  . c  o m

    int orientation;
    try {
        orientation = Integer.valueOf(value);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }

    int screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    switch (orientation) {
    case ANY:
    case UA_DEFAULTS: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        break;
    }
    case LANDSCAPE_PRIMARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;
    }
    case PORTRAIT_PRIMARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    }
    case LANDSCAPE_SECONDARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        break;
    }
    case PORTRAIT_SECONDARY: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        break;
    }
    case LANDSCAPE: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
        break;
    }
    case PORTRAIT: {
        screen_orientation_value = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        break;
    }
    default:
        Log.e(TAG, "Invalid orientation value.");
        return;
    }
    mExtensionContext.getActivity().setRequestedOrientation(screen_orientation_value);
}

From source file:cl.mmoscoso.geocomm.GeoCommMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_geo_comm_main);

    //this.textview_name_user = (TextView) findViewById(R.id.text_view_status);
    //this.button_myroutes = (Button) findViewById(R.id.button_myroutes);        
    this.list_routes = (ListView) findViewById(R.id.list_routes);

    //locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    //locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 0, this);
    list_routes.setClickable(true);//from w  w  w .j a  va2 s .  co m
    list_routes.setOnItemClickListener(this);

    SharedPreferences preferences = getSharedPreferences("userInformation", MODE_PRIVATE);
    SharedPreferences.Editor edit = preferences.edit();
    edit.putBoolean("is_login", false);
    edit.commit();

    getRoutes(new View(this));
}

From source file:com.example.android.animationsdemo.CameraActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DKLog.d(TAG, Trace.getCurrentMethod());
    // 2.setView/*from   w  w  w.  jav  a  2  s.  c  om*/
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_camera);

    initViews();
}

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

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Log.d(Tags.LOG, "- Starting LocalNZB Activity!");
    setContentView(R.layout.localnzb);//from   w  w w. j a v a2  s  .co  m

    listLocalFiles();
}

From source file:edu.chl.dat255.sofiase.readyforapet.viewcontroller.PetActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.petactivity);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    //Receiving the new or saved pet
    if (CreatePetActivity.getPet() != null) {
        dog = (Dog) CreatePetActivity.getPet();
    } else {//from w w  w .  ja  v a 2 s .c o  m
        try {
            dog = (Dog) Pet.load("pet_file.dat", PetActivity.this);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    //Getting the petMood
    petMood = dog.getPetMood();

    //Getting the pet name
    petName = dog.getName();

    //Connecting variables to xml objects
    play = (Button) findViewById(R.id.play);
    walk = (Button) findViewById(R.id.walk);
    eat = (Button) findViewById(R.id.eat);
    sleep = (Button) findViewById(R.id.sleep);
    showPetAge = (TextView) findViewById(R.id.petage);
    petResponse = (TextView) findViewById(R.id.petresponse);
    dogBiscuit = (ImageView) findViewById(R.id.dogbiscuit);
    dogPicture = (ImageView) findViewById(R.id.dogpicture);
    dogBiscuit.setVisibility(View.GONE);
    dogPicture.setVisibility(View.VISIBLE);

    //Initializing the background music
    try {
        afd = getAssets().openFd("readyforapetsong6.m4v");
        player = new MediaPlayer();
        player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
        player.setLooping(true);
        player.prepare();
        player.start();
    } catch (IOException e) {
        e.printStackTrace();
    }

    //Making it possible to turn off music with a checkbox
    addListenerOnMusic();
    musicCheckBox.setChecked(true);

    //Getting the age of the pet if it has not already died
    petAge = (int) (petMood.getCurrentHour() - dog.getBirthHour()) / 24;

    //Setting textview with welcome message
    petResponse.setText("Hello, my name is " + petName + "!");
    petResponse.setVisibility(View.VISIBLE);
    uiHandler.postDelayed(makeTextGone, 2500);

    //Setting textview with current age of the pet
    showPetAge.setText(petName + " is " + petAge + " days old.");
    petResponse.setVisibility(View.VISIBLE);

    //Changing the picture and enabling/disabling buttons depending on mood
    changePicture();

    //Decreasing the moodBar depending on how much time has passed since last eat, walk, play and sleep
    petMood.setFoodMood(petMood.getFoodMood()
            + petMood.moodBarDecrease(petMood.getLastEatHour(), petMood.getCurrentHour()));
    petMood.setWalkMood(petMood.getWalkMood()
            + petMood.moodBarDecrease(petMood.getLastWalkHour(), petMood.getCurrentHour()));
    petMood.setPlayMood(petMood.getPlayMood()
            + petMood.moodBarDecrease(petMood.getLastPlayHour(), petMood.getCurrentHour()));
    petMood.setSleepMood(petMood.getSleepMood()
            + petMood.moodBarDecrease(petMood.getLastSleepHour(), petMood.getCurrentHour()));
    moodBar = (ProgressBar) findViewById(R.id.moodbar);
    moodBar.setProgress(petMood.getSumMood());

    eat.setOnClickListener(new OnClickListener() {
        /**
         * Making the dog feel less hungry if it is hungry and else give the message i'm full.
         * Also shows a picture of a dogbisquit when eating.
         *
         * @param v - View
         */
        @Override
        public void onClick(View v) {

            petResponse = (TextView) findViewById(R.id.petresponse);

            //Disabling buttons when eating
            if (petMood.getFoodMood() < 5) {
                play.setEnabled(false);
                eat.setEnabled(false);
                walk.setEnabled(false);
                sleep.setEnabled(false);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        eat.setEnabled(true);
                        walk.setEnabled(true);
                        play.setEnabled(true);
                        sleep.setEnabled(true);
                        changePicture();
                    }
                }, 10000);

                //Getting the pet response of eating
                petResponse.setText(dog.eat());
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 10000);
                dogBiscuit.setVisibility(View.VISIBLE);
                dogBiscuit.setBackgroundResource(R.anim.animation);

                //Starting animation eating dogbisquit
                final AnimationDrawable anim = (AnimationDrawable) dogBiscuit.getBackground();
                anim.start();
                uiHandler.postDelayed(makeTextGone, 10000);
            }

            else {
                petResponse.setText(dog.eat());
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 5000);
            }
            //Updating the moodbar
            moodBar = (ProgressBar) findViewById(R.id.moodbar);
            moodBar.setProgress(petMood.getSumMood());
        }
    });

    play.setOnClickListener(new OnClickListener() {
        /**
         * Sends the user to PlayActivity if the pet is not too hungry.
         *
         * @param v - View
         */
        @Override
        public void onClick(View v) {
            //Continuing to playActivity only of the dog has not died and is not too hungry
            if ((petMood.getPlayMood() < 5 && petMood.getFoodMood() >= 3) && dog.isAlive()) {
                //Opening PlayActivity and receives a requestCode when resuming this activity
                PetActivity.this.startActivityForResult(new Intent(PetActivity.this, PlayActivity.class), 0);
            } else {
                petResponse.setText(dog.play(0));
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 2000);
            }

            changePicture();
        }
    });

    walk.setOnClickListener(new OnClickListener() {
        /**
         * Sends the user to WalkActivity if the pet wants to walk.
         * When resuming PetActivity a result is received that tells how far the pet walked.
         *
         * @param v - View
         */
        @Override
        public void onClick(View v) {

            petResponse = (TextView) findViewById(R.id.petresponse);

            // Moving to the WalkActivity class if foodMood is high enough and petMood is below 5.
            if (((petMood.getFoodMood() < 3 && petMood.getWalkMood() < 5) || petMood.getWalkMood() == 5)) {
                petResponse.setText(dog.walk(0));
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 2000);
            }

            else if (dog.isAlive()) {
                //Opening PlayActivity and receives a requestCode when resuming this activity
                PetActivity.this.startActivityForResult(new Intent(PetActivity.this, WalkActivity.class), 1);
            }

            else {
                petResponse.setText(dog.walk(0));
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 2000);
            }
            changePicture();
        }
    });

    sleep.setOnClickListener(new OnClickListener() {
        /**
         * Sending the user to SleepActivity if sleepMood is below 5.
         * When resuming PetActivity a result is received that tells how much the pet has slept.
         *
         * @param v - View
         */
        @Override
        public void onClick(View v) {

            if (dog.isAlive() && petMood.getSleepMood() < 5) {
                //Opening PlayActivity if the dog is alive and receives a requestCode when resuming this activity
                PetActivity.this.startActivityForResult(new Intent(PetActivity.this, SleepActivity.class), 2);
            }

            else {
                //Set the pet's response if it is either dead or not sleepy
                petResponse = (TextView) findViewById(R.id.petresponse);
                petResponse.setText(dog.sleep(0));
                petResponse.setVisibility(View.VISIBLE);
                uiHandler.postDelayed(makeTextGone, 2000);
            }
            changePicture();
        }
    });

}