This solution will work forallversions
of Android. You can use reflection in Java to make it work for all Android devices:
Basically you should create a reflection wrapper to call the Android 2.2 setDisplayOrientation, instead of calling the specific method.
The method:
protected void setDisplayOrientation(Camera camera, int angle){
Method downPolymorphic;
try
{
downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
if (downPolymorphic != null)
downPolymorphic.invoke(camera, new Object[] { angle });
}
catch (Exception e1)
{
}
}
And instead of usingcamera.setDisplayOrientation(x)usesetDisplayOrientation(camera,
x):
if (Integer.parseInt(Build.VERSION.SDK) >= 8)
setDisplayOrientation(mCamera, 90);
else
{
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
p.set("orientation", "portrait");
p.set("rotation", 90);
}
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
{
p.set("orientation", "landscape");
p.set("rotation", 90);
}
}
分享到:
相关推荐
There are millions of Android apps out there for people to download how do you make sure yours has the edge? It’s not always about innovation and ideas the most successful apps are those that are ...
android-image-filter some android image filters in some filter, I use NDK to implement to make ...How to Use it It is dead simple, you can see magic in the following code: Bitmap newBitmap = BitmapFilt
No suitable java found.In order to properly use the android developer tools...-附件资源
So you might need to set up Joda-Time properly. With start and end date times specified: val intent = DateTimeRangePickerActivity.newIntent( context, TimeZone.getDefault(), DateTime.now().millis, ...
for how to set the org.gradle.jvmargs property.) Finally, invoke Lint from Gradle as you normally do. Once Lint finishes, performance statistics for each Lint detector should be printed to the console...
How to download and play on Android Head over to the Google Play Store and download the latest release: https://play.google.com/store/apps/details?id=com.jeffreychan.yunnori How to work with the ...
This book will help you construct a great UI for your apps by teaching you how to create custom Android views. You will start by creating your first Android custom view and go through the design ...
Unlike WinXP, VISTA, Windows2000, Windows Nt and Win98, Win7/Win8/... In order to use DB Query Analyzer properly, here I will illustrate how to set ‘-‘ as the default setting of short date in Win7.
NatCam allows you to set the camera's resolution. There are also resolution presets for ease of use. - Photo capture. NatCam allows you to capture high-resolution insta-worthy photos. You also have ...
在FPGA设计中,特别是在使用Xilinx的MIG(Memory Interface Generator)Spartan-6 Memory Controller Block(MCB)时,正确地对ODT(On-Die Termination)、CKE(Clock Enable)和RESET管脚进行端接是至关重要的。...
47. How can the content of this and other SAP Notes with broad tables be displayed properly? 48. How can a SAP HANA connection for SAP support be established? 49. How can I provide input about useful ...
### Android错误解决:Conversion to Dalvik format failed: Unable to execute dex: Wrapper was not properly loaded first 在Android开发过程中,开发者可能会遇到多种类型的错误提示。其中,“Conversion to ...
The purpose of this article is to provide a step-by-step instruction on how to install the DBWS Callout Utilities on Oracle Database Server 10g and how to verify that it works properly. After ...
Chapter 2, Setting Up the .NET Test Environment, explains how to set up your IDE and configure the testing framework so that you can easily run your tests in C# and .NET, with more detail and many ...
You need to arrange them properly to stick tabs at bottom. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@ id/main_content" android:layout_width="match_...
This guide does not attempt to teach what cryptography is, or how to use it properly. Learning cryptography takes time, and there are books and resources available that teach this subject very well. ...