在PublishWorkActivity里面这样操作
1,替换掉这个方法
// 调用系统的相机获取图片 private void setToCamera() { isShowPic = false; publish_PicLayout.setVisibility(View.GONE); File tmpFile; File sdCardDir = Environment.getExternalStorageDirectory(); if(Environment.getExternalStorageState().equals (android.os.Environment.MEDIA_MOUNTED)){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); ContentValues values = new ContentValues(); imageFilePath = Environment.getExternalStorageDirectory() .getAbsolutePath() + "/YouJiao/xxt_teacher/pic/"+System.currentTimeMillis ()+".jpg";//设置图片的保存路径 app.setImgpath(imageFilePath); File imageFile = new File(imageFilePath);//通过路径创建保存文件 photoUri = Uri.fromFile(imageFile); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri); startActivityForResult(intent, 1); }else{ Toast.makeText(PublishWorkActivity.this, "SD卡不存在,不能进行拍照功能..", Toast.LENGTH_SHORT).show(); } }
2,添加变量
private String imageFilePath=””;
private App app;
3, oncreate里面添加初始化
app=(App)getApplicationContext();
4,在onActivityResult的拍照返回那里,改成这样
imageFilePath=app.getImgpath();