2017-08-08 8 views
-1

6.0のAndroidスタジオでエミュレータで上記のクラッシュが発生しましたが、6.0.1のデバイスでクラッシュは発生していません。エミュレータはカメラを起動することがありますが、logcatの何もない状態でほとんどがクラッシュして正しい方向に向いています。誰でもここで何が起こっているのかについての手掛かりはありますか?残念ながら、カメラはエラーを停止しました。アンドロイド6.0.0

また、実際に通過したときのイメージもあります。 Image_capture_camera

private File createImageFile() throws IOException 
{ 
    // Create an image file name 
    String timeStamp = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss").format(new Date()); 
    String imageFileName = "" + timeStamp; 
    File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES); 
    File image = File.createTempFile(
      imageFileName, /* prefix */ 
      ".jpg",   /* suffix */ 
      storageDir  /* directory */ 
    ); 

    Name = imageFileName; 
    // Save a file: path for use with ACTION_VIEW intents 
    mCurrentPhotoPath = image.getAbsolutePath(); 
    return image; 
} 

private void dispatchTakePictureIntent() 
{ 
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    // Ensure that there's a camera activity to handle the intent 
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) 
    { 
     // Create the File where the photo should go 
     File photoFile = null; 
     try 
     { 
      photoFile = createImageFile(); 
     } 
     catch (IOException ex) 
     { 
      // Error occurred while creating the File 
     } 
     // Continue only if the File was successfully created 
     if (photoFile != null) 
     { 
      photoURI = FileProvider.getUriForFile(getActivity(), 
        "com.full.jusuf.snaphealth.fileprovider", 
        photoFile); 
      takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); 
      startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); 
     } 
    } 
} 

@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) 
{ 
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) 
    { 

     final Uri uri = photoURI; 
     uri_data.add(new Timeline_Model(uri.toString(), Name)); 

     //save data to firebase 
     FirebaseStorage storage = FirebaseStorage.getInstance(); 
     StorageReference storageRef = storage.getReference().child("users").child(FirebaseAuth.getInstance().getCurrentUser().getUid()); 
     storageRef.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(Name).putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { 
      @Override 
      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) 
      { 
       String uri1 = taskSnapshot.getDownloadUrl().toString(); 
       FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); 
       DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference(); 
       if (user != null) 
       { 
        long Count = System.currentTimeMillis(); 
        databaseReference.child("users").child(user.getUid()).child("image_uri").child("image" + Count).setValue(new Timeline_Model(uri1, Name)); 
       } 
      } 
     }); 

     PopulateGallery(); 
    } 
} 

Logcat:

08-08 02:22:26.576 17275-17330/com.full.jusuf.snaphealth V/FA: Recording user engagement, ms: 10526 
08-08 02:22:26.576 17275-17330/com.full.jusuf.snaphealth V/FA: Using measurement service 
08-08 02:22:26.576 17275-17330/com.full.jusuf.snaphealth V/FA: Connecting to remote service 
08-08 02:22:26.580 17275-17330/com.full.jusuf.snaphealth D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=10526, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=4121746325476785971}] 
08-08 02:22:26.593 17275-17330/com.full.jusuf.snaphealth V/FA: Using measurement service 
08-08 02:22:26.593 17275-17330/com.full.jusuf.snaphealth V/FA: Connection attempt already in progress 
08-08 02:22:26.593 17275-17330/com.full.jusuf.snaphealth V/FA: Activity paused, time: 917202 
08-08 02:22:26.611 17275-17330/com.full.jusuf.snaphealth D/FA: Connected to remote service 
08-08 02:22:26.611 17275-17330/com.full.jusuf.snaphealth V/FA: Processing queued up service tasks: 2 
08-08 02:22:26.678 17275-17357/com.full.jusuf.snaphealth D/EGL_emulation: eglMakeCurrent: 0x7f9ce78225e0: ver 3 1 (tinfo 0x7f9cdb3c2d40) 
08-08 02:22:26.679 17275-17357/com.full.jusuf.snaphealth E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f9cdb6c53e0 
+0

あなたの問題解決すべきであることを見てきましたあなたのアプリケーションが6.0で動作するように、カメラのランタイム許可。 –

答えて

0

あなたはおそらく知っているように、Androidの23を使用すると、ターゲットので、もし23+、完全にアクセス許可ポリシーを変更する(または最新の、あなたはおそらくん)それはおそらくあなたのですここでの問題は、ここで

File storageDir = getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES); 
File image = File.createTempFile(
     imageFileName, /* prefix */ 
     ".jpg",   /* suffix */ 
     storageDir  /* directory */ 
); 

または

です10

(この読み:Android M Camera Intent + permission bug?)を

あなたのマニフェストで

< uses-permission android:name="android.permission.CAMERA" /> 

< uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

を持っていることを確認し、その後、設定に移動 - >アプリケーション - > yourApp - >権限と必ず保管し、カメラがチェックされていることを確認。クラッシュが手動で設定された権限で再現されなくなった場合は、 https://developer.android.com/training/permissions/requesting.html と進み、アプリケーションで使用するすべての機能にランタイム許可要求を追加します。

+0

返信いただきありがとうございますが、動作しませんでした。手動で権限を設定することも同じことでした。不思議にも、シミュレータ上でカメラアプリを起動すると動作しますが、上にリンクした画像と同じグラフィカルグリッチが表示されます。 – jusuf

+0

がハードウェアの問題である可能性があります。別のエミュレータをランダムに作成し、カメラをWebcamNの代わりにエミュレートするように設定してください。 – Nick

+0

エミュレートされたカメラで新しいエミュレータで同じ問題が発生しました。 – jusuf

0

私は長い間、これで苦労して、あなたはランタイム権限を要求する必要があり、最大のAndroid API 23からと、AndroidのドキュメントでRuntime Permissionsを読んで、それはあなたが追加する必要が

+0

これは問題ありません。nexus 5 6.0.1と6.0 api 23のシミュレータ以外のすべてのデバイスでうまく動作します。ハードウェアでs8をテストし、メモ5が6.0.1を実行していることをテストしました7.0と問題はありません。私は原因を追跡することはできないようだ。 – jusuf

関連する問題