2016-03-23 21 views
0

Resim çekildikten sonra görüntü ekranında resim yüklenirken siyah ekran belirir. Ben camera360 uygulamasını kullanarak fotoğraf çekmeye çalışıyorum ve onay işaretini tıkladığımda görüntüyü imageView uygulamasında yüklemeliyim. Bu, Google Kamera uygulamasıyla iyi çalışıyor. Ama aynı resim galeriden yüklüyse, o zaman imageView içinde düzgün bir şekilde yüklenir.Camera360 App

private void TakePic() { 
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
    startActivityForResult(intent, TAKE_PICTURE); 
    } 


@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) { 
     Uri filePath = data.getData(); 
     try { 
      //Getting the Bitmap from Gallery 
      bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath); 
      //Setting the Bitmap to ImageView 
      imageView.setImageBitmap(bitmap); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } else{ 
     if(resultCode==RESULT_OK){ 
     bitmap = (Bitmap) data.getExtras().get("data"); 
     imageView.setImageBitmap(bitmap); 
    }} 
} 

cevap

0

Bu i belki değil, belki de size yardımcı olacaktır galeriden seçtikten sonra bir imageView benim resim yüklemek nasıl. düğmesi tıklandığında

requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { 
      Uri selectedImage = data.getData(); 
      String[] filePathColumn = { MediaStore.Images.Media.DATA }; 

      Cursor cursor = getContentResolver().query(selectedImage, 
        filePathColumn, null, null, null); 
      cursor.moveToFirst(); 
      int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 
      String picturePath = cursor.getString(columnIndex); 
      cursor.close(); 

      ImageView imageView = (ImageView) findViewById(R.id.imageView); 
      imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath)); 

:

Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
      startActivityForResult(i, RESULT_LOAD_IMAGE); 

      if (ContextCompat.checkSelfPermission(MainComp_News_Edit.this, 
        Manifest.permission.READ_EXTERNAL_STORAGE) 
        != PackageManager.PERMISSION_GRANTED) { 

       // Should we show an explanation? 
       if (ActivityCompat.shouldShowRequestPermissionRationale(MainComp_News_Edit.this, 
         Manifest.permission.READ_EXTERNAL_STORAGE)) { 

        // Show an expanation to the user *asynchronously* -- don't block 
        // this thread waiting for the user's response! After the user 
        // sees the explanation, try again to request the permission. 

       } else { 

        // No explanation needed, we can request the permission. 

        ActivityCompat.requestPermissions(MainComp_News_Edit.this, 
          new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 
          MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); 
       } 
      } 
+1

galeriden çalışıyor, ancak Camera360 ile resmi boş ekranda gösteriyor. – user2269164

+0

Oh üzgün bu bölümü kaçırdı, goodluck –

0

Eğer ana iş parçacığı uygulamasında kameradan resim yükleme başlıca nedeni Its. Asynctask'ta onActivityResult içeriğini sarmayı deneyin.