2
I would like to know how to remove the option "Photos" from the options selector and leave only the options "Camera" and "Gallery". As well as not working, it is unnecessary since the "Gallery" does the same thing and better. Below follows my code and the result:
Activity Editarcontaactivity:
public class EditarContaActivity extends Activity implements OnClickListener {
private static int RESULT_LOAD_IMAGE = 1;
Button btneditar;
File file;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_editarconta);
imguser = (ImageView)findViewById(R.id.imgdefault_user);
btneditar = (Button)findViewById(R.id.btneditar1);
btneditar.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_editarconta, menu);
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//Detects request codes
if(requestCode == RESULT_LOAD_IMAGE && resultCode == Activity.RESULT_OK) {
Bitmap bitmap = null;
Bundle extras = data.getExtras();
bitmap = extras.getParcelable("data");
FileOutputStream fos;
try {
fos = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
imguser.setImageBitmap(bitmap);
}
}
public void onClick(View v) {
// TODO Auto-generated method stub
String filename = "profile.jpg";
file = new File(Environment.getExternalStorageDirectory(), filename);
Intent testeIntent = CarregarImagem.pegaIntencao(this, file);
startActivityForResult(testeIntent, RESULT_LOAD_IMAGE);
}
}
Cargo class:
public class CarregarImagem {
public static Intent pegaIntencao(Context contexto, File file) {
// Intenção da Câmera
final List<Intent> cameraIntents = new ArrayList<Intent>();
final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final PackageManager packageManager = contexto.getPackageManager();
final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
for (ResolveInfo res : listCam){
final String packageName = res.activityInfo.packageName;
final Intent intent = new Intent(captureIntent);
intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
intent.setPackage(packageName);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
cameraIntents.add(intent);
}
// Intenção da Galeria
final Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Seletor de opções
final Intent chooserIntent = Intent.createChooser(galleryIntent, "Foto de Perfil");
// Add opção de camera
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[]{}));
return chooserIntent;
}
}
But the watts app does not allow appear this option, I think it is pq it does not work, so when I click on it appears the photos, but while selecting any photo the app causes an error.
– Gustavo Almeida Cavalcante
I just checked here that Whatsapp displays a lot of apps to choose from, including Photos: ( https://i.imgur.com/pdAHuLh.jpg ) If Photos doesn’t work for the action you want, this is the problem you have to solve. Even if you can, it is not good to limit the preferences of the (a) user(a). I also had this problem once and made it work. You too can.
– Pablo Almeida
Did you check it out where? Because I was talking about the part where you’re gonna change your profile picture and not the part about texting.
– Gustavo Almeida Cavalcante
This part is in settings/Profile.
– Gustavo Almeida Cavalcante
I went to settings/profile.
– Pablo Almeida
Seriously because in my does not appear this option, appears only gallery, camera and the option to remove photo, already when I run the app of this project appears.
– Gustavo Almeida Cavalcante
I just checked on another phone here and this option appears, I think this option Photos from my phone is not working or the Watts App checks if the option will work first before displaying. I really don’t know how I would do this kind of check if that’s the case.
– Gustavo Almeida Cavalcante
@Gustavoalmeidacavalcante Open another question specifically for this.
– Pablo Almeida