- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 stackoverflow 和 google 搜索了很多。我需要计算我的相机和指定对象之间的距离。
为此,我需要找到相机的焦距。我也创建了示例项目,但它创建了 Null Pointer Exception。请帮忙..
代码如下。
public class MainActivity extends Activity {
Camera mcamera;
int focul_length;
Parameters params;
File mFile;
public int PICTURE_ACTIVITY_CODE = 1;
public String FILENAME = "sdcard/photo.jpg";
Camera.Parameters cameraParameters;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
launchTakePhoto();
}
private void launchTakePhoto()
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraParameters = mcamera.getParameters();
CameraInfo myinfo = new CameraInfo();
float l=cameraParameters.getFocalLength(); // Here its creating Null Pointer Exception
mFile = new File(FILENAME);
System.out.println("My Focul Length:--"+l);
Uri outputFileUri = Uri.fromFile(mFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, PICTURE_ACTIVITY_CODE);
}
Also If possible please provide the code to get angle of Elevation.If possible.I need this very badly.I need your help guys!!
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == PICTURE_ACTIVITY_CODE)
{
if (resultCode == RESULT_OK)
{
ImageView myimageView = (ImageView) findViewById(R.id.imageView1);
Uri inputFileUri = Uri.fromFile(mFile);
myimageView.setImageURI(inputFileUri);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
最佳答案
您是否正在初始化 Camera 对象?在你的 onCreate()
mcamera = Camera.open();
关于android - 如何找到android相机的焦距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18531896/
例如,我有一个父类Author: class Author { String name static hasMany = [ fiction: Book,
代码如下: dojo.query(subNav.navClass).forEach(function(node, index, arr){ if(dojo.style(node, 'd
我有一个带有 Id 和姓名的学生表和一个带有 Id 和 friend Id 的 Friends 表。我想加入这两个表并找到学生的 friend 。 例如,Ashley 的 friend 是 Saman
我通过互联网浏览,但仍未找到问题的答案。应该很容易: class Parent { String name Child child } 当我有一个 child 对象时,如何获得它的 paren
我正在尝试创建一个以 Firebase 作为我的后端的社交应用。现在我正面临如何(在哪里?)找到 friend 功能的问题。 我有每个用户的邮件地址。 我可以访问用户的电话也预订。 在传统的后端中,我
我主要想澄清以下几点: 1。有人告诉我,在 iOS 5 及以下版本中,如果您使用 Game Center 设置多人游戏,则“查找 Facebook 好友”(如与好友争夺战)的功能不是内置的,因此您需要
关于redis docker镜像ENTRYPOINT脚本 docker-entrypoint.sh : #!/bin/sh set -e # first arg is `-f` or `--some-
我是一名优秀的程序员,十分优秀!