Simple button click image preview
up vote
0
down vote
favorite
I want to make a simple button for image preview and this code works fine, but when I open the image using Google Photos (cause that's the only gallery app I got on my Xiaomi phone) the picture couldn't load, just black screen and the loading circle in the middle trying to open the image, but never doing that.
Any idea how can i fix this?
private static final int EXPLICIT_ACTIVITY_REQUEST_CODE = 0;
private static final int PICK_IMAGE = 1;
public void onStart_Picture(View view){
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent{pickIntent});
startActivityForResult(chooserIntent, PICK_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == PICK_IMAGE)
{
if(resultCode == RESULT_OK)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri imageUri = data.getData();
intent.setDataAndType(imageUri,"image/*");
startActivity(intent);
}
}
}
add a comment |
up vote
0
down vote
favorite
I want to make a simple button for image preview and this code works fine, but when I open the image using Google Photos (cause that's the only gallery app I got on my Xiaomi phone) the picture couldn't load, just black screen and the loading circle in the middle trying to open the image, but never doing that.
Any idea how can i fix this?
private static final int EXPLICIT_ACTIVITY_REQUEST_CODE = 0;
private static final int PICK_IMAGE = 1;
public void onStart_Picture(View view){
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent{pickIntent});
startActivityForResult(chooserIntent, PICK_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == PICK_IMAGE)
{
if(resultCode == RESULT_OK)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri imageUri = data.getData();
intent.setDataAndType(imageUri,"image/*");
startActivity(intent);
}
}
}
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to make a simple button for image preview and this code works fine, but when I open the image using Google Photos (cause that's the only gallery app I got on my Xiaomi phone) the picture couldn't load, just black screen and the loading circle in the middle trying to open the image, but never doing that.
Any idea how can i fix this?
private static final int EXPLICIT_ACTIVITY_REQUEST_CODE = 0;
private static final int PICK_IMAGE = 1;
public void onStart_Picture(View view){
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent{pickIntent});
startActivityForResult(chooserIntent, PICK_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == PICK_IMAGE)
{
if(resultCode == RESULT_OK)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri imageUri = data.getData();
intent.setDataAndType(imageUri,"image/*");
startActivity(intent);
}
}
}
I want to make a simple button for image preview and this code works fine, but when I open the image using Google Photos (cause that's the only gallery app I got on my Xiaomi phone) the picture couldn't load, just black screen and the loading circle in the middle trying to open the image, but never doing that.
Any idea how can i fix this?
private static final int EXPLICIT_ACTIVITY_REQUEST_CODE = 0;
private static final int PICK_IMAGE = 1;
public void onStart_Picture(View view){
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");
Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent{pickIntent});
startActivityForResult(chooserIntent, PICK_IMAGE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == PICK_IMAGE)
{
if(resultCode == RESULT_OK)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri imageUri = data.getData();
intent.setDataAndType(imageUri,"image/*");
startActivity(intent);
}
}
}
asked Nov 15 at 13:52
NickUnique
62
62
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53320990%2fsimple-button-click-image-preview%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown