我想从sdcard文件路径获取文件名.例如:/storage/sdcard0/DCIM/Camera/1414240995236.jpg I want get 1414240995236.jpg
我已经编写了代码来获取相同的但它无法正常工作.请帮忙.
以下是我的代码:
@Override
protected void onActivityResult( int requestCode, int resultCode, Intent data)
{
if ( requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if ( resultCode == RESULT_OK) {
/*********** Load Captured Image And Data Start ****************/
String imageId = convertImageUriToFile( imageUri,CameraActivity);
// Create and excecute AsyncTask to load capture image
new LoadImagesFromSDCard().execute(""+imageId);
/*********** Load Captured Image And Data End ****************/
} else if ( resultCode == RESULT_CANCELED) {
Toast.makeText(this, " Picture was not taken ", Toast.LENGTH_SHORT).show();
} …Run Code Online (Sandbox Code Playgroud) 我提到了很多链接,但我仍然无法得到任何意义,我可以开始我的开发.我想用相机测量我的图像高度,宽度和距离.我发现这个应用程序.我想让这种类型的应用程序不完全相同但完全相同但是根据我的要求,我想用相机测量我的图像高度,宽度和距离.
任何人都可以给我/建议我正确的方式或任何例子,以便我可以更多地了解这个要求.
我试过这个:
http://android-er.blogspot.in/2012/04/gets-distances-from-camera-to-focus.html
我想使用该bulkTransfer功能在相机和Android平板电脑设备之间交换数据/命令.我写了这个Activity,但该方法bulkTransfer返回-1(错误状态).为什么会返回错误?
public class MainActivity extends Activity {
private TextView text;
private int TIMEOUT = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.txt);
usbTest();
}
private void usbTest() {
UsbDevice device = (UsbDevice) getIntent().getParcelableExtra(
UsbManager.EXTRA_DEVICE);
if (device == null)
text.setText("device null");
else
text.setText("device not null");
UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = manager.getDeviceList();
text.setText(text.getText() + "\nDevices connected: "
+ deviceList.values().size());
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
while (deviceIterator.hasNext()) {
device …Run Code Online (Sandbox Code Playgroud) 当我连续点击"捕获"按钮(没有任何中断)时,获取运行时异常如何解决此问题?
如果它不可能,那我怎么处理这个例外?
btnCapture = (ImageButton) findViewById(R.id.btnCapture);
final MediaPlayer mp = MediaPlayer.create(CameraLauncherActivity.this, R.raw.button);
btnCapture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// line where getting RuntimeException
camera.takePicture(null, null, mPicture);
}
});
Run Code Online (Sandbox Code Playgroud)
日志:
02-12 14:48:41.580: E/AndroidRuntime(6997): FATAL EXCEPTION: main
02-12 14:48:41.580: E/AndroidRuntime(6997): java.lang.RuntimeException: takePicture failed
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.hardware.Camera.native_takePicture(Native Method)
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.hardware.Camera.takePicture(Camera.java:1126)
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.hardware.Camera.takePicture(Camera.java:1071)
02-12 14:48:41.580: E/AndroidRuntime(6997): at app.cam.shane.CameraLauncherActivity$3.onClick(CameraLauncherActivity.java:116)
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.view.View.performClick(View.java:4223)
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.view.View$PerformClick.run(View.java:17275)
02-12 14:48:41.580: E/AndroidRuntime(6997): at android.os.Handler.handleCallback(Handler.java:615) …Run Code Online (Sandbox Code Playgroud) 我正在开发一个库,使Camera开发人员更容易使用API.
Droid Incredible 2在纵向模式下使用后置摄像头无法拍照.具体来说,我在LogCat中得到了这个序列:
08-18 09:25:52.094: E/QualcommCameraHardware(1368): native_get_picture: MSM_CAM_IOCTL_GET_PICTURE fd 25 error Connection timed out
08-18 09:25:52.094: E/QualcommCameraHardware(1368): getPicture failed!
08-18 09:25:52.094: E/QualcommCameraHardware(1368): get picture failed, giving jpeg callback with NULL data
Run Code Online (Sandbox Code Playgroud)
这些消息出现约5秒钟后,我打电话takePicture()的Camera,这与一些旧的源代码,我看到适合QualcommCameraHardware,设置了一个5000毫秒超时的ioctl()通话发言的摄像头硬件.
最终结果是onPictureTaken()传递了一个null byte[]JPEG数据,这意味着我们没有照片.
该设备可在所有其他测试配置中使用我的代码,包括使用前置摄像头以纵向模式工作.
有没有人知道可能导致这种特殊失败的特定事物?
UPDATE
我无法再重现错误.我会删除这个问题,但一旦有答案,这显然是不可能的.
我有一个移动网站,允许用户使用文件输入类型(浏览按钮)上传照片.如果可能的话,我想点击浏览按钮或任何其他HTML按钮启动Android设备的相机应用程序.这可能吗?
我读了这篇类似的帖子,但在他们的例子中,他们询问如何将相机应用程序注册为Intent Receiver以上传图像.与此类似,我只想以Android浏览器选择电话号码和地址的方式启动相机应用程序.
如何在自定义相机中捕获图像,然后将该图像保存在android中?
我有一个纵向模式的相机应用程序,它从前端和后端相机拍摄照片.我将图像保存在我的SD卡中并尝试找到相应的exif值,它总是给出0.但是我得到了预期的exif方向存储在设备中的其他图像的值(如下载的图片).
我怎样才能解决这个问题 ?谁能帮我吗 ?
这是用于保存图片和查找方向的代码
PictureCallback myPictureCallback_JPG = new PictureCallback() {
@Override
public void onPictureTaken(byte[] arg0, Camera arg1) {
// TODO Auto-generated method stub
try {
File APP_FILE_PATH = new File(Environment.getExternalStorageDirectory()
.getPath() + "/Myapp/");
if (!APP_FILE_PATH.exists()) {
APP_FILE_PATH.mkdirs();
}
File file = new File(APP_FILE_PATH, "image.jpg");
FileOutputStream fos = new FileOutputStream(file);
fos.write(arg0);
fos.close();
imageFileUri=Uri.fromfile(file); getApplicationContext().getContentResolver().notifyChange(
imageFileUri, null);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
} catch (Exception e) {
}
}
};
Run Code Online (Sandbox Code Playgroud)
以下是surphace创建和更改函数的代码 …
我在安装了Google Analytics的Google Play商店中安装了相机应用.我一直收到以下崩溃报告:
getParameters失败(空参数)
我的问题是:处理这个问题的正确方法是什么?
查看它发生在哪里的Android源代码没有给我任何额外的细节.android_hardware_Camera.cpp中抛出错误:
String8 params8 = camera->getParameters();
if (params8.isEmpty()) {
jniThrowRuntimeException(env, "getParameters failed (empty parameters)");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
查看开源Android相机,看看它如何处理这种情况也不是很有帮助.调用getParameters时,该代码似乎没有捕获RuntimeException.(除非在一个案例中他们抓住它,关闭相机,然后重新抛出它).
有没有正确的方法来处理这个?
如果没有,这种情况经常发生的原因是什么?
注意:在任何一天,我有5k到8k活跃用户.在这些例外中有40-70之间.这对我来说似乎很高兴.我知道有一些合法的例子,相机可能无法初始化.但1%的用户似乎不合理.此外,由于Android相机应用程序不处理异常,它真的让我想知道是否有其他根本原因.
我几天来一直在与这个功能作斗争......
看来,相机忽略了(?)我定义的焦点区域.以下是代码片段:
聚焦:
protected void focusOnTouch(MotionEvent event) {
if (camera != null) {
Rect rect = calculateFocusArea(event.getX(), event.getY());
Parameters parameters = camera.getParameters();
parameters.setFocusMode(Parameters.FOCUS_MODE_AUTO);
parameters.setFocusAreas(Lists.newArrayList(new Camera.Area(rect, 500)));
camera.setParameters(parameters);
camera.autoFocus(this);
}
}
Run Code Online (Sandbox Code Playgroud)
重点区域计算:
private Rect calculateFocusArea(float x, float y) {
int left = clamp(Float.valueOf((x / getSurfaceView().getWidth()) * 2000 - 1000).intValue(), focusAreaSize);
int top = clamp(Float.valueOf((y / getSurfaceView().getHeight()) * 2000 - 1000).intValue(), focusAreaSize);
return new Rect(left, top, left + focusAreaSize, top + focusAreaSize);
}
Run Code Online (Sandbox Code Playgroud)
几个日志事件来自 Camera.AutoFocusCallback#onAutoFocus
Log.d(TAG, String.format("Auto focus success=%s. Focus mode: '%s'. …