2024.5.13(第二阶段冲刺第一天)

所学时间:2小时

代码行数:126行

博客园数:1篇

所学知识:

1.我昨天的成就:开会了解第二阶段大致的方向

2.遇到什么困难:导航栏无法正常显示图片

3.今天的任务:准备写一个拍照系统,可以拍完照片把店家显示到前台,还可以传输到后端数据库

4.今天所敲的代码:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@RequiresApi(api = Build.VERSION_CODES.N)
  private void openCamera(){
      String imageName = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date());
      //File outputImage = new File(requireContext().getExternalCacheDir(), imageName+".jpg");
      File outputImage = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), imageName+".jpg");
      Objects.requireNonNull(outputImage.getParentFile()).mkdirs();
      try
      {
          if(outputImage.exists())
          {
              outputImage.delete();
          }
          boolean a = outputImage.createNewFile();
          Log.e("createNewFile", String.valueOf(a));
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
 
      imageUri= FileProvider.getUriForFile(requireContext(), "com.example.teamwork.fileprovider",outputImage);
      path=imageUri.getPath();
      Log.e("存储的拍照路径为:::",path);
      Intent intent0=new Intent("android.media.action.IMAGE_CAPTURE");
      intent0.putExtra(MediaStore.EXTRA_OUTPUT,imageUri);
      startActivityForResult(intent0,TAKE_PHOTO);
  }

  

posted @   kuku睡  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端
点击右上角即可分享
微信分享提示