【问题标题】:simple camera intent on android tablet and smartphone安卓平板电脑和智能手机上的简单相机意图
【发布时间】:2015-01-14 02:49:29
【问题描述】:

最近我开始为我的智能手机 (motog) 进行开发,并且能够使用简单的摄像头 OnActivityForResult intent 运行一个小型数据捕获程序。

当我在手机上运行它时,它运行起来就像一个魅力,一切都按我希望的那样工作。

我尝试将我的程序安装到平板设备 (Monster m7)。在平板电脑上,程序运行没有问题,然后我点击相机按钮,活动开始,程序将我发送到我可以捕捉照片的相机视图,但程序没有将文件保存在它应该保存的位置是(相同的程序在手机中运行良好)意图的代码是下一个

    private void photo(String NE) {

        if (!NOMA.getText().toString().equals("")) {
            System.out.println("uno");
            Intent cameraa = new Intent("android.media.action.IMAGE_CAPTURE");
            System.out.println("dos");
            File root = android.os.Environment.getExternalStorageDirectory(); 
            File dir = new File (root.getAbsolutePath() + "/SCR_ELECTRICO/Photos/"+NOMA.getText().toString());
            if (!dir.exists()) {
                dir.mkdirs();  
            }
            String timeStamp = new SimpleDateFormat("dd.MM.yyyy 'a' h:mm:ss a").format(new Date());
            File Photo = new File(dir,NOMA.getText().toString()+ NE+"_"+timeStamp+".jpg");
            imageuri= Uri.fromFile(Photo);
            cameraa.putExtra(MediaStore.EXTRA_OUTPUT,imageuri);

            startActivityForResult(cameraa,1);
        } else {
            Toast.makeText(getBaseContext(),"Asigna un nombre",
                 Toast.LENGTH_SHORT).show();
        }
    }

    protected void onActivityResult2(int requestCode, int resultCode, Intent cameraa) {  
        super.onActivityResult(requestCode, resultCode, cameraa);
        if(resultCode==Activity.RESULT_OK) {
            getContentResolver().notifyChange(imageuri,null);
        }
    }

我已经对此进行了一些研究,但我没有找到任何可以解决此问题的方法。

【问题讨论】:

  • 它会抛出任何异常吗?
  • 在“/SCR_ELECTRICO/Photos/”中没有创建任何内容?你是怎么检查的?
  • 使用 ES 文件浏览器应用程序,使用相同的应用程序我能够在智能手机中查看文件

标签: android android-intent camera tablet smartphone


【解决方案1】:

嗯,这很奇怪。我退出了时间戳字符串,现在我可以拍照了

String nombrefin=NOMA.getText().toString()+ NE+"_"+".jpg";
    File Photo = new File(dir,nombrefin);

程序不接受 date 命令的一些原因,我需要它。 好吧,我还有更多的研究要做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-16
    • 2014-03-27
    • 1970-01-01
    • 2013-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多