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.golang.app.WViewActivity.java

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

    //Fixed Portrait orientation
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    /*this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);*/

    setContentView(R.layout.webview);//ww  w  .  j a va  2s  .com
    WebView webView = (WebView) findViewById(R.id.webView1);

    initWebView(webView);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            Log.d("JavaGoWV: ", url);

            final Pattern p = Pattern.compile("dcoinKey&password=(.*)$");
            final Matcher m = p.matcher(url);
            if (m.find()) {
                try {
                    Thread thread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                //File root = android.os.Environment.getExternalStorageDirectory();
                                File dir = Environment
                                        .getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
                                Log.d("JavaGoWV", "dir " + dir);

                                URL keyUrl = new URL(
                                        "http://127.0.0.1:8089/ajax?controllerName=dcoinKey&first=1"); //you can write here any link
                                //URL keyUrl = new URL("http://yandex.ru/"); //you can write here any link
                                File file = new File(dir, "dcoin-key.png");

                                long startTime = System.currentTimeMillis();
                                Log.d("JavaGoWV", "download begining");
                                Log.d("JavaGoWV", "download keyUrl:" + keyUrl);

                                /* Open a connection to that URL. */
                                URLConnection ucon = keyUrl.openConnection();

                                Log.d("JavaGoWV", "0");
                                /*
                                * Define InputStreams to read from the URLConnection.
                                */
                                InputStream is = ucon.getInputStream();

                                Log.d("JavaGoWV", "01");

                                BufferedInputStream bis = new BufferedInputStream(is);

                                Log.d("JavaGoWV", "1");
                                /*
                                * Read bytes to the Buffer until there is nothing more to read(-1).
                                */
                                ByteArrayBuffer baf = new ByteArrayBuffer(5000);
                                int current = 0;
                                while ((current = bis.read()) != -1) {
                                    baf.append((byte) current);
                                }

                                Log.d("JavaGoWV", "2");
                                /* Convert the Bytes read to a String. */
                                FileOutputStream fos = new FileOutputStream(file);
                                fos.write(baf.toByteArray());
                                fos.flush();
                                fos.close();

                                Log.d("JavaGoWV", "3");
                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                                    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
                                    Uri contentUri = Uri.fromFile(file);
                                    mediaScanIntent.setData(contentUri);
                                    WViewActivity.this.sendBroadcast(mediaScanIntent);
                                } else {
                                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
                                            Uri.parse("file://" + Environment.getExternalStorageDirectory())));
                                }

                                Log.d("JavaGoWV", "4");
                            } catch (Exception e) {
                                Log.e("JavaGoWV error 0", e.toString());
                                e.printStackTrace();
                            }
                        }
                    });
                    thread.start();

                } catch (Exception e) {
                    Log.e("JavaGoWV error", e.toString());
                    e.printStackTrace();
                }
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            Log.e("JavaGoWV", "shouldOverrideUrlLoading " + url);

            if (url.endsWith(".mp4")) {
                Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(in);
                return true;
            } else {
                return false;
            }
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Log.d("JavaGoWV",
                    "failed: " + failingUrl + ", error code: " + errorCode + " [" + description + "]");
        }
    });

    SystemClock.sleep(1500);
    //if (MyService.DcoinStarted(8089)) {
    webView.loadUrl("http://localhost:8089/");
    //}

}

From source file:com.repay.android.frienddetails.FriendDetailsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // If the available screen size is that of an average tablet (as defined
    // in the Android documentation) then allow the screen to rotate
    if (getResources().getBoolean(R.bool.lock_orientation)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//from   w ww  . j  av  a  2s.  c  om

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_frienddetails);
    mDB = new DatabaseHandler(this);
    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Bundle bundle = getIntent().getExtras();
    try {
        if (bundle != null) {
            mFriend = new Friend(bundle.getString(Friend.REPAYID),
                    Uri.parse(bundle.getString(Friend.LOOKUPURI)), bundle.getString(Friend.NAME),
                    new BigDecimal(bundle.getString(Friend.AMOUNT)));
        }
    } catch (NullPointerException e) {
        Log.i(TAG, "Person added by name, not from contacts list");
        if (bundle != null) {
            mFriend = new Friend(bundle.getString(Friend.REPAYID), null, bundle.getString(Friend.NAME),
                    new BigDecimal(bundle.getString(Friend.AMOUNT)));
        }
    }

    // Set the message for the info dialog
    mInfoMessage = R.string.activity_debtHistoryInfoDialog_message_debtHistoryInfo;

    // See if we need to use a tab view or just a 2 fragment layout,
    // this boolean is stored in XML, this way I can use the SDK
    // size qualifiers to determine phone or tablet
    mUseTabs = getResources().getBoolean(R.bool.use_tabView);

    // Determine whether this is a tablet or not so
    // we know if we need the tab view or just a couple
    // of FrameLayouts
    if (!mUseTabs) {
        mFragMan = getSupportFragmentManager().beginTransaction();
        mOverViewFrag = new FriendOverviewFragment();
        mDebtHistoryFrag = new DebtHistoryFragment();
        mFragMan.add(R.id.activity_frienddetails_frame1, mOverViewFrag);
        mFragMan.add(R.id.activity_frienddetails_frame2, mDebtHistoryFrag);
        mFragMan.commit();

    } else {
        mTabView = (ViewPager) findViewById(R.id.activity_frienddetails_tabView);
        // Get the friend from the bundle passed in the intent

        // Produce the Tab bar
        mActionBar = getActionBar();
        if (mActionBar != null) {
            mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        }
        ViewPager.SimpleOnPageChangeListener mViewPagerListener = new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                // Find the ViewPager Position
                mActionBar.setSelectedNavigationItem(position);
            }
        };
        mTabView.setOnPageChangeListener(mViewPagerListener);
        // Set the ViewPager animation
        mTabView.setPageTransformer(true, new DepthPageTransformer());
        // Capture tab button clicks
        ActionBar.TabListener tabListener = new ActionBar.TabListener() {

            @Override
            public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) {
                // Not needed
            }

            @Override
            public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
                mTabView.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) {
                // Not needed
            }
        };

        // Create first Tab
        Tab mTab1 = mActionBar.newTab().setText(mFriend.getName()).setTabListener(tabListener);
        mActionBar.addTab(mTab1);

        // Create second Tab
        Tab mTab2 = mActionBar.newTab().setText("Debts").setTabListener(tabListener);
        mActionBar.addTab(mTab2);

        // Add Tabs to ViewPager
        mFragments = new ArrayList<Fragment>();
        mFragments.add(FriendOverviewFragment.newInstance("Friend Details"));
        mFragments.add(DebtHistoryFragment.newInstance("Debt History"));

        // Instantiate adapter and add it to ViewPager
        mTabAdapter = new TabViewAdapter(getSupportFragmentManager(), mFragments);
        mTabView.setAdapter(mTabAdapter);
    }
}

From source file:info.papdt.blacklight.ui.common.AbsActivity.java

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

    int lang = Utility.getCurrentLanguage(this);
    if (lang != mLang) {
        recreate();/*from  w  w  w .  j a  v a  2 s  .  co  m*/
    }

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    if (mSettings.getBoolean(Settings.SHAKE_TO_RETURN, true)) {
        mDetector.addListener(this);
    }
}

From source file:org.gdgsp.fragment.CheckinFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    view = inflater.inflate(R.layout.fragment_checkin, container, false);

    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
    ImageView qr = (ImageView) view.findViewById(R.id.checkin_qrcode);

    byte[] qrBase64 = Base64.decode(preferences.getString("qr_code", ""), Base64.DEFAULT);
    Bitmap qrImage = BitmapFactory.decodeByteArray(qrBase64, 0, qrBase64.length);

    qr.setImageBitmap(qrImage);//from  w ww .j a  v a 2s .  c o  m

    if (preferences.contains("member_profile")) {
        Gson gson = new Gson();

        Type datasetListType = new TypeToken<Person>() {
        }.getType();
        Person person = gson.fromJson(preferences.getString("member_profile", ""), datasetListType);

        TextView name = (TextView) view.findViewById(R.id.name);
        name.setText(person.getName());
    }

    activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    return view;
}

From source file:com.adguard.android.ui.utils.ActivityUtils.java

public static void setPortraitOnly(Activity activity) {
    if (activity.getResources().getBoolean(R.bool.portraitOnly) || getSmallestScreenSize(activity) <= 320) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//from   w w w  .j  av  a 2  s .  c  o  m
}

From source file:kr.wdream.ui.IntroActivity.java

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

    Log.d(LOG_TAG, "onCreate");

    // ? /* w  w w. j  av a2s  .  c o m*/
    if (AndroidUtilities.isTablet()) {
        setContentView(kr.wdream.storyshop.R.layout.intro_layout_tablet);
        View imageView = findViewById(kr.wdream.storyshop.R.id.background_image_intro);
        BitmapDrawable drawable = (BitmapDrawable) getResources()
                .getDrawable(kr.wdream.storyshop.R.drawable.catstile);
        drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        imageView.setBackgroundDrawable(drawable);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(kr.wdream.storyshop.R.layout.intro_layout);
    }

    if (LocaleController.isRTL) {
        icons = new int[] { kr.wdream.storyshop.R.drawable.intro7, kr.wdream.storyshop.R.drawable.intro6,
                kr.wdream.storyshop.R.drawable.intro5, kr.wdream.storyshop.R.drawable.intro4,
                kr.wdream.storyshop.R.drawable.intro3, kr.wdream.storyshop.R.drawable.intro2,
                kr.wdream.storyshop.R.drawable.intro1 };
        titles = new int[] { kr.wdream.storyshop.R.string.Page7Title, kr.wdream.storyshop.R.string.Page6Title,
                kr.wdream.storyshop.R.string.Page5Title, kr.wdream.storyshop.R.string.Page4Title,
                kr.wdream.storyshop.R.string.Page3Title, kr.wdream.storyshop.R.string.Page2Title,
                kr.wdream.storyshop.R.string.Page1Title };
        messages = new int[] { kr.wdream.storyshop.R.string.Page7Message,
                kr.wdream.storyshop.R.string.Page6Message, kr.wdream.storyshop.R.string.Page5Message,
                kr.wdream.storyshop.R.string.Page4Message, kr.wdream.storyshop.R.string.Page3Message,
                kr.wdream.storyshop.R.string.Page2Message, kr.wdream.storyshop.R.string.Page1Message };
    } else {
        icons = new int[] { kr.wdream.storyshop.R.drawable.intro1, kr.wdream.storyshop.R.drawable.intro2,
                kr.wdream.storyshop.R.drawable.intro3, kr.wdream.storyshop.R.drawable.intro4,
                kr.wdream.storyshop.R.drawable.intro5, kr.wdream.storyshop.R.drawable.intro6,
                kr.wdream.storyshop.R.drawable.intro7 };
        titles = new int[] { kr.wdream.storyshop.R.string.Page1Title, kr.wdream.storyshop.R.string.Page2Title,
                kr.wdream.storyshop.R.string.Page3Title, kr.wdream.storyshop.R.string.Page4Title,
                kr.wdream.storyshop.R.string.Page5Title, kr.wdream.storyshop.R.string.Page6Title,
                kr.wdream.storyshop.R.string.Page7Title };
        messages = new int[] { kr.wdream.storyshop.R.string.Page1Message,
                kr.wdream.storyshop.R.string.Page2Message, kr.wdream.storyshop.R.string.Page3Message,
                kr.wdream.storyshop.R.string.Page4Message, kr.wdream.storyshop.R.string.Page5Message,
                kr.wdream.storyshop.R.string.Page6Message, kr.wdream.storyshop.R.string.Page7Message };
    }

    initView();

}

From source file:com.tester.photodetectortest.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (Build.VERSION.SDK_INT >= 23) {
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 28);
        }/*  w  w  w  . j a  va2 s  .c  o m*/
    }
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    startDetector();
}

From source file:cordova.plugins.screenorientation.CDVOrientation.java

private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) {

    String action = args.optString(0);

    String orientation = args.optString(1);

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

    Activity activity = cordova.getActivity();

    if (orientation.equals(ANY)) {
        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);
    }/*ww w.j  a  va2  s .  c  om*/

    callbackContext.success();
    return true;

}

From source file:im.ene.lab.toro.sample.activity.ShowCaseActivity.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_show_case);
    String name = getIntent().getStringExtra(EXTRA_FRAGMENT_NAME);
    setTitle(getFragmentTitle(name));/*from   w w w .java2s  . co m*/

    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.container);
    if (fragment == null) {
        fragment = getFragment(name);
        if (fragment != null) {
            getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
        }
    }
}

From source file:com.landenlabs.allperfimages.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from   ww w . ja  v a  2  s .  c  om
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(mViewPager);

    /*
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show();
    }
    });
    */

}