Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>public class Set_image extends Activity implements OnClickListener { Button btn_capture_image,btn_share_from_gallery; ImageView iv_set_image; private static final int REQUEST_CODE = 1; private static final int CAMERA_REQUEST = 1888; String filePath=""; Bitmap Main_bitmap; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.set_image); btn_capture_image =(Button) findViewById(R.id.button_capture_image); btn_share_from_gallery =(Button) findViewById(R.id.button_share_from_gallery); iv_set_image = (ImageView) findViewById(R.id.imageView_set_iamge); btn_capture_image.setOnClickListener(this); btn_share_from_gallery.setOnClickListener(this); } public void onClick(View v) { if (v == btn_capture_image) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, CAMERA_REQUEST); } if (v == btn_share_from_gallery) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, REQUEST_CODE); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_REQUEST) { Main_bitmap = (Bitmap) data.getExtras().get("data"); iv_set_image.setImageBitmap(Main_bitmap); } if (requestCode == REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK) try { Uri selectedImage = data.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA}; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); if (cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(filePathColumn[0]); filePath = cursor.getString(columnIndex); BitmapFactory.Options options4 = new BitmapFactory.Options(); options4.inSampleSize = 1; Main_bitmap = BitmapFactory.decodeFile(filePath, options4); iv_set_image.setImageBitmap(Main_bitmap); } cursor.close(); } catch (Exception e) { e.printStackTrace(); } super.onActivityResult(requestCode, resultCode, data); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload