Back to project page iPhoroidUI.
The source code is released under:
Apache License
If you think the Android project iPhoroidUI listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (c) 2011 by KLab Inc., All rights reserved. */*from ww w .jav a 2s . co m*/ * Programmed by Naohide Sano */ package org.klab.iphoroid.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import android.app.Activity; import android.content.res.AssetManager; import android.content.res.Configuration; import android.util.Log; import android.view.Display; /** * ActivityUtil. * * @author <a href="mailto:sano-n@klab.jp">Naohide Sano</a> (sano-n) * @version 0.00 2011/07/06 sano-n initial version <br> */ public abstract class ActivityUtil { private static final String TAG = "ActivityUtil"; /** * ??????????????????????????????? * * @see "http://stackoverflow.com/questions/2795833/check-orientation-on-android-phone" */ public static int getScreenOrientation(Activity activity) { Display getOrient = activity.getWindowManager().getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if (getOrient.getWidth() == getOrient.getHeight()) { orientation = Configuration.ORIENTATION_SQUARE; } else { if (getOrient.getWidth() < getOrient.getHeight()) { orientation = Configuration.ORIENTATION_PORTRAIT; } else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; } /** * ?????????????????????????????????????????. * * @param activity * @param fileName ??????? * @param charset ??????????????? * @return ????????? */ public static String loadAssetsText(Activity activity, String fileName, String charset) { return loadAssetsText(activity.getResources().getAssets(), fileName, charset); } /** * ?????????????????????????????????????????. * * @param assetManager * @param fileName ??????? * @param charset ??????????????? * @return ????????? */ public static String loadAssetsText(AssetManager assetManager, String fileName, String charset) { String text = null; try { BufferedReader br = new BufferedReader(new InputStreamReader(assetManager.open(fileName), charset)); StringBuilder sb = new StringBuilder(); while ((text = br.readLine()) != null) { sb.append(text); } text = sb.toString(); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } return text; } } /* */