findSomeElement.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){/*this can also be getApplicationContext(), the important is to get the context*/newAlertDialog.Builder(this())/*Instead */.setTitle("Title").setMessage("Mensaje").setPositiveButton("Camera",newDialogInterface.OnClickListener(){publicvoidonClick(DialogInterfacedialog,intwhich){/*Calling the camera*/Intentintent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);startActivityForResult(intent,0);dialog.cancel();}}).setNegativeButton("Gallery",newDialogInterface.OnClickListener(){publicvoidonClick(DialogInterfacedialog,intwhich){/*Select Image from Gallery*/Intentintent=newIntent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);intent.setType("image/*");startActivityForResult(intent,0);dialog.cancel();}}).setIcon(android.R.drawable.ic_dialog_alert).show();}});
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.