public void takepic(View view) {
TextView schtitle = (TextView) findViewById(R.id.Sitename);
String schname = schtitle.getText().toString();
String[] tokens = schname.split(" ");
String timeStamp = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss").format(new Date());
String imageFileName = tokens[0] + "-" + timeStamp + ".jpg";
TextView myAwesomeTextView = (TextView)findViewById(R.id.filetext);
//in your OnCreate() method
myAwesomeTextView.setText(imageFileName);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String name = imageFileName;
File file = new File(path, name );
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
}
有什么需要帮忙的吗
标记
问题是不再允许文件://uri。
相反,您必须使用FileProvider。
看看这里:https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en