Guest User

Untitled

a guest
Jan 20th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. mFile = context.getFilesDir().getAbsoluteFile();
  2. mDisplayMetrics = context.getResources().getDisplayMetrics();
  3. connMan = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  4. final double x = Math.pow(mDisplayMetrics.widthPixels / mDisplayMetrics.xdpi, 2);
  5. final double y = Math.pow(mDisplayMetrics.heightPixels / mDisplayMetrics.ydpi, 2);
  6. mScreenInches = Math.sqrt(x + y);
  7.  
  8. @Override
  9. public void onConfigurationChanged(Configuration newConfig) {
  10. super.onConfigurationChanged(newConfig);
  11.  
  12. // Checks the orientation of the screen
  13. if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
  14. Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
  15. } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
  16. Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
  17. }
  18. }
Add Comment
Please, Sign In to add comment