最近的博客解释说我们必须使用
<meta-data android:name="android.max_aspect" android:value="2.1" />
Run Code Online (Sandbox Code Playgroud)
在AndroidManifest.xml的<application>元素中,可在超宽屏设备上实现最佳显示效果,例如Samsung Galaxy S8.
为了验证这一点,我安装我的应用程序(不max_aspect,没有resizeableActivity标志; targetSdkVersion=22,compileSdkVersion=24)在Android 7.1.1.仿真器具有自定义2960x1440分辨率.所有活动,包括身临其境,填充屏幕没有边距,如博客文章中所示.
我明确地补充道
<meta-data android:name="android.max_aspect" android:value="1.5" />
Run Code Online (Sandbox Code Playgroud)
这对模拟器也没有影响.
所以,问题是:这个元标志只在真实设备上检查过,还是我的模拟器错过了一些配置?
更新:我试图联系引用博客文章的作者Neto Marin.我发现了一条引以为傲的推文
关于他对全球Android Dev社区的贡献,但无法得到他的回答.
我第一次尝试使用泽西的WebService.以下是我从一些博客获得的代码.当我使用jersey客户端尝试Java Web服务时,我遇到了500错误
javax.servlet.ServletException: Servlet.init() for servlet Jersey Root REST Service threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
com.sun.jersey.api.core.servlet.WebAppResourceConfig.init(WebAppResourceConfig.java:102)
com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:89)
com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:74)
com.sun.jersey.spi.container.servlet.WebComponent.getWebAppResourceConfig(WebComponent.java:672)
com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:415)
com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:582)
com.sun.jersey.spi.container.servlet.WebServletConfig.getDefaultResourceConfig(WebServletConfig.java:87)
com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:703)
com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
javax.servlet.GenericServlet.init(GenericServlet.java:160)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)'
Run Code Online (Sandbox Code Playgroud)
下面是我的web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>RestFulWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Root …Run Code Online (Sandbox Code Playgroud) 在尝试使用Android Camera2实现触控聚焦功能时,我遇到了一个问题.
理论很简单:
MeteringRectangle出来的结果,并在一个新的使用CaptureRequest有很多例子展示了如何处理第一点和最后一点,但没有多少以可理解的方式处理第二点和第三点.文档和示例并不是很清楚,可能会让人感到困惑.
开始了...
该CameraCharacteristics.SENSOR_ORIENTATIONIS形容为
顺时针角度,输出图像需要通过该角度以原始方向旋转到设备屏幕上.
知道传感器坐标系定义为(0,0)是有源像素阵列中的左上角像素,我将其读作将传感器坐标系中捕获的图像旋转到可能产生的位置所需的角度图像在原始方向上看起来很直立.因此,如果传感器的顶部朝向具有纵向原始方向的手机的右侧,SENSOR_ORIENTATION则将为90°.

获得的显示方向mActivity.getWindowManager().getDefaultDisplay().getRotation();记录为:
返回屏幕从"自然"方向的旋转.返回的值可能是Surface.ROTATION_0(无旋转),Surface.ROTATION_90,Surface.ROTATION_180或Surface.ROTATION_270.例如,如果设备具有自然高的屏幕,并且用户将其侧面转向横向,则此处返回的值可以是Surface.ROTATION_90或Surface.ROTATION_270,具体取决于它的转向.角度是屏幕上绘制图形的旋转,这是设备物理旋转的相反方向.例如,如果设备逆时针旋转90度,则补偿渲染将顺时针旋转90度,因此返回的值将为Surface.ROTATION_90.
我发现这个定义比传感器定位更清晰,没有解释的地方.
现在事情开始变得难看......
我决定使用Camera2Raw示例中提供的方法来获取从传感器方向到设备方向的旋转.
/**
* Rotation need to transform from the camera sensor orientation to the device's current
* orientation.
*
* @param c the {@link CameraCharacteristics} to query for the camera sensor
* orientation.
* @param deviceOrientation the current device orientation relative to the native device
* orientation.
* @return the …Run Code Online (Sandbox Code Playgroud) 我想在ImageView中使用显示从相机拍摄的图像
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
Run Code Online (Sandbox Code Playgroud)
到目前为止,此工作正常,但在用户使用所选的相机应用程序拍摄照片后,会出现一个对话框(可能来自应用程序),询问是否保存或删除拍摄的照片(至少在Android 2.3和4.2上使用默认的相机应用程序).
我想跳过这个额外的对话框,直接在ImageView中显示图像(当调用onActivityResult时),因为这意味着用户需要额外的交互步骤,这是不必要的,因为他可以保存或删除照片.我的应用.
这可以使用简单的ACTION_IMAGE_CAPTURE Intent,还是需要更复杂的东西,比如Camera Preview和SurfaceView?
您可能知道三星Galaxy s4能够同时捕获前置和后置摄像头.现在我需要在我的应用程序中捕获它们.我应该下载什么吗?
我试图打开它们但是没有成功!我正在使用API级别17.
我正在使用相机拍摄照片的Android应用程序.为了启动相机,我使用的intent ACTION_IMAGE_CAPTURE是这样的:
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File image=new File(Environment.getExternalStorageDirectory(),"PhotoContest.jpg");
camera.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(image));
imageUri=Uri.fromFile(image);
startActivityForResult(camera,1);
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case 1:
if (resultCode == Activity.RESULT_OK) {
selectedImage = imageUri;
getContentResolver().notifyChange(selectedImage, null);
image= (ImageView) findViewById(R.id.imageview);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
image.setImageBitmap(bitmap);
Toast.makeText(this, selectedImage.toString(),
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
.show();
Log.e("Camera", e.toString());
}
}
else
if(resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(EditPhoto.this, …Run Code Online (Sandbox Code Playgroud) 我用这段代码从相机中捕捉图像.
package android.takeowneship;
import java.io.File;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.widget.ImageView;
import android.widget.Toast;
public class camera extends Activity{
private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 100;
Uri imageUri;
private ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//define the file-name to save photo taken by Camera activity
String fileName = "new-photo-name.jpg";
//create parameters for Intent with filename
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture …Run Code Online (Sandbox Code Playgroud) 1- 一些同事(使用android工作室的Android开发人员)在我的手机上测试他的应用程序时遇到了问题(这是一个与android 6.0.1相关的问题),他面临的问题是当他拿一个来自画廊的图像可以和他一起工作,但是当从相机拍摄照片时它没有显示,他怀疑他在手机上保存的图像没有得到保存,他怀疑这是一个许可问题,对他来说是有效的在星系上而不是在nexus上.
2- 同样的事情发生在我的团结中我买了一个过去常常在我的手机上工作的插件(当我拍摄相机照片时),现在我更新后它不再拍摄图像,我的意思是我走了相机并返回应用程序,而不像以前那样加载到视图中.
这是logcat显示的内容
--------- beginning of main
02-07 16:36:10.272 203-813/? D/audio_hw_primary? out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
02-07 16:36:10.282 203-813/? D/audio_hw_primary? select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
02-07 16:36:10.282 203-813/? D/msm8974_platform? platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
02-07 16:36:10.282 203-813/? D/audio_hw_primary? enable_snd_device: snd_device(2: speaker)
02-07 16:36:10.284 203-813/? D/audio_hw_primary? enable_audio_route: apply and update mixer path: low-latency-playback
02-07 16:36:10.289 24484-24484/? W/CAM_ActivityCloser? WARNING: Activity was artificially finished: CameraActivityController was closed.
02-07 16:36:10.302 24484-24484/? I/CAM_2RsmeActvtyFltr? START onPause: Activity = com.android.camera.util.activity.DoubleOnResumeActivityFilter@d1e256d
02-07 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用libx264为Android构建FFMPEG.
我可以成功构建和使用FFMPEG for Android但我意识到我需要编码的能力,因此我试图用x264构建FFMPEG.
我正在使用本教程为Android构建FFmpeg http://www.roman10.net/how-to-build-ffmpeg-for-android/
在尝试构建FFMPEG时出现错误:
"错误:未找到libx264"
在我的日志中它说:
"/usr/local/lib/libx264.a:无法读取符号:存档没有索引;运行ranlib添加一个..."
我有FFMPEG和x264的最新版本.我知道FFMPEG在usr/lib和usr/include中查找头文件和库,所以为了使它找到x264我使用cflags和ldflags:
我尝试构建x264,其中有许多不同的选项,互联网上的其他人都说我需要.例如.--enable-shared, - enable-static, - disable-pthreads等.有些论坛说启用这个,其他人说没有禁用它.
任何帮助将不胜感激,谢谢
编辑:
如果我使用最简单的命令构建FFmpeg以包含libx264,那么它可以工作.即.
./configure --enable-gpl --enable-libx264 --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --enable-static --enable-shared
Run Code Online (Sandbox Code Playgroud)
但是我需要它适用于Android.我使用的脚本是:
NDK=~/Desktop/android-ndk-r7
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--enable-shared \
--enable-static \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS -I/usr/local/include" \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L …Run Code Online (Sandbox Code Playgroud) 我讨厌警告.我们的Android项目现在有151个,而且我确信在列表的某个地方有一个实际上警告我们免受潜在的麻烦.
这些警告中的一种是关于不推荐使用的字段和方法.这可能很有用,除了Manifest包含<uses-sdk android:minSdkVersion="10" />,并且这些警告只考虑了targetSDK android-17.
可以轻松地将这些警告静音 - @SuppressWarnings("deprecation")在违规行或整个方法之前添加注释.但这忽略了它的全部要点 - 如果/当我们决定改变时minSdkVersion="11",在10级弃用的API仍然不会出现,并且有人将不得不在我们所有的项目中查看所有注释,以找到必须的代码被重写.
是否有一些解决方案可以根据我的minSdkVersion管理这些警告?
似乎Mark在下面发布了一个有趣的答案,甚至提出了一个受我的问题启发的功能请求,但我不同意minSdkVersion的重要性.他希望看到@TargetApi(NN)基于目标API级别的弃用警告(很可能来自Lint,类似于注释).但我不同意这种方法.
考虑一个打开相机的简单应用程序.它可能想要检查预览帧速率.但是这种方法在API 9中已弃用,现在我们必须检查预览FPS范围.如果我们使用platforms/android-8/android.jar,Java编译器将不会显示弃用警告.
但即使应用程序在支持此类查询的设备上运行,它也不允许我们找到首选的视频分辨率.我们可能会在@TargetApi(11)那里添加注释,以确保应用程序是使用platforms/android-11/android.jar或更高版本构建的.
现在我们已经定位了Honeycomb及更高版本,将为getPreviewFrameRate()显示弃用警告,这正是困扰我的.有一段时间,我想象的应用程序必须支持一些Froyo设备,因此我别无选择,只能设置minSdkVersion=8并使用已弃用的方法.当然,我将在条件块中使用任何高级API,并且已经@TargetApi(NN)到位.幸运的是,对于Donut和更高版本,当检测到对不存在的方法或成员的调用时,类加载器不会崩溃,并且仅仅在if()中包装可疑调用就足够了.
那我该怎么办?添加getPreviewFrameRate()@SuppressWarnings("deprecation")调用来静音警告?改为添加?@SuppressDeprecation(8)
但在某些时候,我将决定与Froyo的向后兼容性不再重要.我设置<uses-sdk android:minSdkVersion="9" />了我的Manifest,但getPreviewFrameRate()的弃用警告仍被抑制......好吧,新方法肯定比现有的注释更好,因为grep -R "@SuppressDeprecation(8)"在Manifest中进行更改后,整个项目更容易.
但我更喜欢这里更紧密的集成:让Lint为我解析Manifest文件. …