Advertisement
Hanif_Amrullah

Phone/Tablet

Apr 1st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1.   // Program untuk tau tablet atau phone      
  2.  
  3.         DisplayMetrics metrics = new DisplayMetrics();
  4.         this.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  5.         float yInches= metrics.heightPixels/metrics.ydpi;
  6.         float xInches= metrics.widthPixels/metrics.xdpi;
  7.         double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches);
  8.         Log.d("xxx", "Ini Apa :" + diagonalInches);
  9.         if (diagonalInches>=6.5){
  10.                  Log.d("xxx", "Ini Tablet :" + diagonalInches);
  11.        }else{
  12.             Log.d("xxx", "Ini phone :" + diagonalInches);
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement