I am trying to create a simply interface where users can take a picture and display it as "Player 1" or "Player 2".
When the user clicks add picture the blue android skateboarding icon should be replaced with the captured picture. Although, it works perfectly fine on a Galaxy S1. It does not work on a LG G2.
On the LG G2, when the picture is taken in portrait the displayed photo is rotated 90 degrees. When taken in landscape, it does not display at all.
Here is my code:
private View.OnClickListener onClickListener = new View.OnClickListener()
{
@Override
public void onClick(final View v)
{
switch(v.getId())
{
case R.id.p1_bn: //Player one Button
Intent p1i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(p1i.resolveActivity(getPackageManager()) != null)
{
player = 1;
startActivityForResult(p1i, REQUEST_CODE);
}
break;
case R.id.p2_bn: //Player 2 Button
Intent p2i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(p2i.resolveActivity(getPackageManager()) != null)
{
player = 2;
startActivityForResult(p2i, REQUEST_CODE);
}
break;
}
}
};
public void onActivityResult(int requestcode, int resultcode, Intent data)
{
if (requestcode==REQUEST_CODE)
{
if (resultcode==RESULT_OK)
{
Bundle bundle = data.getExtras();
Bitmap BMP;
BMP = (Bitmap) bundle.get("data");
if (player == 1)
{
p1_IMG.setImageBitmap(null); //remove icon
p1_IMG.setImageBitmap(BMP); //set new icon
}
else if (player == 2)
{
p2_IMG.setImageBitmap(null);
p2_IMG.setImageBitmap(BMP);
}
}
}
}
Any help or suggestions would be gladly appreciated. Thank you.
0 comments:
Post a Comment