小编Gar*_*ryP的帖子

如何让camera2 api再次工作?

我正在使用 Xamarin/Android (不是 Forms),尝试将camera2basic api 示例集成到我的项目中。 https://developer.xamarin.com/samples/monodroid/android5.0/Camera2Basic/

我在示例中没有进行任何更改,我只对使用主摄像头和拍摄快照感兴趣。

我的项目有一个 MainActivity,camera2 是它的片段之一,我这样调用:

 string fragmentTag = this.Resources.GetString(Resource.String.camera_form);

 // Begin the transaction
 FragmentTransaction trans = this.FragmentManager.BeginTransaction();

 // Replace the old fragment with the new one.
 trans.Add(Resource.Id.fragment_container, camera2BasicFragment, fragmentTag);

 // Add the transaction to the back stack.
 // The tag is added so we can use PopBackStack to skip a screen on the back key
 trans.AddToBackStack(fragmentTag);

 // Don't forget to commit
 trans.Commit();
Run Code Online (Sandbox Code Playgroud)

一切都是第一次。它拍摄照片并将其保存到文件夹中。

我第二次运行它时,它显示预览,然后当我拍照时它在这里崩溃,抛出的位置是:

  public void CaptureStillPicture()
  {
     try
     {
        var activity = Activity; …
Run Code Online (Sandbox Code Playgroud)

xamarin android-camera2

2
推荐指数
1
解决办法
1812
查看次数

标签 统计

android-camera2 ×1

xamarin ×1