Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mFile = context.getFilesDir().getAbsoluteFile();
- mDisplayMetrics = context.getResources().getDisplayMetrics();
- connMan = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
- final double x = Math.pow(mDisplayMetrics.widthPixels / mDisplayMetrics.xdpi, 2);
- final double y = Math.pow(mDisplayMetrics.heightPixels / mDisplayMetrics.ydpi, 2);
- mScreenInches = Math.sqrt(x + y);
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- // Checks the orientation of the screen
- if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
- } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
- Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
- }
- }
Add Comment
Please, Sign In to add comment