Jump to content

adrien38270

Membre
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutre

About adrien38270

  • Rank
    Newbie
  1. bonjour Quand je clic sur prendre photo 1 sa m’ouvre appareil photo sa prend la photo la ces tout bon mes apartir de la je suis perdu sa me la mais sur tout les autre imageview package fr.ga.adrien.dpartmod; import android.content.Intent; import android.graphics.Bitmap; import android.os.Bundle; import android.provider.MediaStore; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { Button BtnPrendrePhoto1; Button BtnPrendrePhoto2; Button BtnPrendrePhoto3; Button BtnPrendrePhoto4; ImageView imgAffichePhoto1; ImageView imgAffichePhoto2; ImageView imgAffichePhoto3; ImageView imgAffichePhoto4; public static final int REQUEST_ID_IMAGE_CAPTURE = 1000; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.BtnPrendrePhoto1 = this.findViewById(R.id.PrendrePhoto1); this.BtnPrendrePhoto2 = this.findViewById(R.id.PrendrePhoto2); this.BtnPrendrePhoto3 = this.findViewById(R.id.PrendrePhoto3); this.BtnPrendrePhoto4 = this.findViewById(R.id.PrendrePhoto4); this.imgAffichePhoto1 = this.findViewById(R.id.AffichePhoto1); this.imgAffichePhoto2 = this.findViewById(R.id.AffichePhoto2); this.imgAffichePhoto3 = this.findViewById(R.id.AffichePhoto3); this.imgAffichePhoto4 = this.findViewById(R.id.AffichePhoto4); this.BtnPrendrePhoto1.setOnClickListener(v -> captureImage1(imgAffichePhoto1)); this.BtnPrendrePhoto2.setOnClickListener(v -> captureImage2(imgAffichePhoto2)); this.BtnPrendrePhoto3.setOnClickListener(v -> captureImage3(imgAffichePhoto3)); this.BtnPrendrePhoto4.setOnClickListener(v -> captureImage4(imgAffichePhoto4)); } void captureImage1(ImageView imfAffinePhoto1) { this.imgAffichePhoto1 = imfAffinePhoto1; // Create an implicit intent, for image capture. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Start camera and wait for the results. this.startActivityForResult(intent, REQUEST_ID_IMAGE_CAPTURE); } void captureImage2(ImageView imfAffinePhoto2) { this.imgAffichePhoto2 = imfAffinePhoto2; // Create an implicit intent, for image capture. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Start camera and wait for the results. this.startActivityForResult(intent, REQUEST_ID_IMAGE_CAPTURE); } void captureImage3(ImageView imfAffinePhoto3) { this.imgAffichePhoto3 = imfAffinePhoto3; // Create an implicit intent, for image capture. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Start camera and wait for the results. this.startActivityForResult(intent, REQUEST_ID_IMAGE_CAPTURE); } void captureImage4(ImageView imfAffinePhoto4) { this.imgAffichePhoto4 = imfAffinePhoto4; // Create an implicit intent, for image capture. Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Start camera and wait for the results. this.startActivityForResult(intent, REQUEST_ID_IMAGE_CAPTURE); } // When results returned @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_ID_IMAGE_CAPTURE) { if (resultCode == RESULT_OK) { Bitmap bp = (Bitmap) data.getExtras().get("data"); imgAffichePhoto1.setImageBitmap(bp); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Action canceled", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Action Failed", Toast.LENGTH_LONG).show(); } } super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_ID_IMAGE_CAPTURE) { if (resultCode == RESULT_OK) { Bitmap bp = (Bitmap) data.getExtras().get("data"); imgAffichePhoto2.setImageBitmap(bp); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Action canceled", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Action Failed", Toast.LENGTH_LONG).show(); } } super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_ID_IMAGE_CAPTURE) { if (resultCode == RESULT_OK) { Bitmap bp = (Bitmap) data.getExtras().get("data"); imgAffichePhoto3.setImageBitmap(bp); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Action canceled", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Action Failed", Toast.LENGTH_LONG).show(); } } super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_ID_IMAGE_CAPTURE) { if (resultCode == RESULT_OK) { Bitmap bp = (Bitmap) data.getExtras().get("data"); imgAffichePhoto4.setImageBitmap(bp); } else if (resultCode == RESULT_CANCELED) { Toast.makeText(this, "Action canceled", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Action Failed", Toast.LENGTH_LONG).show(); } } } }
×
×
  • Create New...