Android 8.1 Closes Activity when startActivityForResult() is called












2















somebody come to my rescue.
I am building an android application that require taking a picture from the device camera and loading the thumbnail into an ImageView, note that I don't want to save this image, I only want to load it into an ImageView and get bitmap drawable from the ImageView later.



This is what I have Implemented:
To launch the camera:



Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(cameraIntent.resolveActivity(activityWeakReference.get().getPackageManager()) != null){
startActivityForResult(cameraIntent, UPLOAD_PICTURE_CAMERA);
}


Below is onActivityResult(int requestCode, int resultCode, Intent data) invoked when startActivityForResult() is called:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == UPLOAD_PICTURE_CAMERA) {
try{
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageViewphoto.setImageBitmap(imageBitmap);

}catch (Exception e){
Log.e(TAG, Utility.stringify(e));
}
}


The Problem:
The above code works well up to android 7.0, but on Oreo 8.1, the activity closes immediately the Camera is opened so onActivityResult() is not called.



This is all the log I could get:



I/PhoneWindow: isNeedChangeStatusBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@c7a24ee] size: 1
isAPPNeedChangeSBColor pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeStatusBarColor false
I/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@5566d8f] size: 1
I/PhoneWindow: isAPPNeedChange pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeNaviBarColor false
generateLayout mNavigationBarColor: ff000000
I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
I/zygote: Do full code cache collection, code=505KB, data=398KB
I/zygote: After code cache collection, code=495KB, data=332KB
D/BaseActivity: On Pause is called
I/zygote: Do partial code cache collection, code=505KB, data=341KB
I/zygote: After code cache collection, code=505KB, data=341KB
Increasing code cache capacity to 2MB
D/BaseActivity: On Stop is called
Disconnected from the target VM, address: 'localhost:8857', transport: 'socket'


Who is facing the same issue on Oreo?, any advice would be appreciated.










share|improve this question

























  • Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

    – Anurag Chutani
    Nov 23 '18 at 14:06











  • @AnuragChutani, do you mean Camera permissions?

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:15











  • Any crash log ?

    – Benjamin
    Nov 23 '18 at 14:15











  • I have edited the question and added the log, that is all the log I could get

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:22


















2















somebody come to my rescue.
I am building an android application that require taking a picture from the device camera and loading the thumbnail into an ImageView, note that I don't want to save this image, I only want to load it into an ImageView and get bitmap drawable from the ImageView later.



This is what I have Implemented:
To launch the camera:



Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(cameraIntent.resolveActivity(activityWeakReference.get().getPackageManager()) != null){
startActivityForResult(cameraIntent, UPLOAD_PICTURE_CAMERA);
}


Below is onActivityResult(int requestCode, int resultCode, Intent data) invoked when startActivityForResult() is called:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == UPLOAD_PICTURE_CAMERA) {
try{
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageViewphoto.setImageBitmap(imageBitmap);

}catch (Exception e){
Log.e(TAG, Utility.stringify(e));
}
}


The Problem:
The above code works well up to android 7.0, but on Oreo 8.1, the activity closes immediately the Camera is opened so onActivityResult() is not called.



This is all the log I could get:



I/PhoneWindow: isNeedChangeStatusBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@c7a24ee] size: 1
isAPPNeedChangeSBColor pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeStatusBarColor false
I/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@5566d8f] size: 1
I/PhoneWindow: isAPPNeedChange pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeNaviBarColor false
generateLayout mNavigationBarColor: ff000000
I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
I/zygote: Do full code cache collection, code=505KB, data=398KB
I/zygote: After code cache collection, code=495KB, data=332KB
D/BaseActivity: On Pause is called
I/zygote: Do partial code cache collection, code=505KB, data=341KB
I/zygote: After code cache collection, code=505KB, data=341KB
Increasing code cache capacity to 2MB
D/BaseActivity: On Stop is called
Disconnected from the target VM, address: 'localhost:8857', transport: 'socket'


Who is facing the same issue on Oreo?, any advice would be appreciated.










share|improve this question

























  • Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

    – Anurag Chutani
    Nov 23 '18 at 14:06











  • @AnuragChutani, do you mean Camera permissions?

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:15











  • Any crash log ?

    – Benjamin
    Nov 23 '18 at 14:15











  • I have edited the question and added the log, that is all the log I could get

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:22
















2












2








2








somebody come to my rescue.
I am building an android application that require taking a picture from the device camera and loading the thumbnail into an ImageView, note that I don't want to save this image, I only want to load it into an ImageView and get bitmap drawable from the ImageView later.



This is what I have Implemented:
To launch the camera:



Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(cameraIntent.resolveActivity(activityWeakReference.get().getPackageManager()) != null){
startActivityForResult(cameraIntent, UPLOAD_PICTURE_CAMERA);
}


Below is onActivityResult(int requestCode, int resultCode, Intent data) invoked when startActivityForResult() is called:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == UPLOAD_PICTURE_CAMERA) {
try{
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageViewphoto.setImageBitmap(imageBitmap);

}catch (Exception e){
Log.e(TAG, Utility.stringify(e));
}
}


The Problem:
The above code works well up to android 7.0, but on Oreo 8.1, the activity closes immediately the Camera is opened so onActivityResult() is not called.



This is all the log I could get:



I/PhoneWindow: isNeedChangeStatusBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@c7a24ee] size: 1
isAPPNeedChangeSBColor pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeStatusBarColor false
I/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@5566d8f] size: 1
I/PhoneWindow: isAPPNeedChange pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeNaviBarColor false
generateLayout mNavigationBarColor: ff000000
I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
I/zygote: Do full code cache collection, code=505KB, data=398KB
I/zygote: After code cache collection, code=495KB, data=332KB
D/BaseActivity: On Pause is called
I/zygote: Do partial code cache collection, code=505KB, data=341KB
I/zygote: After code cache collection, code=505KB, data=341KB
Increasing code cache capacity to 2MB
D/BaseActivity: On Stop is called
Disconnected from the target VM, address: 'localhost:8857', transport: 'socket'


Who is facing the same issue on Oreo?, any advice would be appreciated.










share|improve this question
















somebody come to my rescue.
I am building an android application that require taking a picture from the device camera and loading the thumbnail into an ImageView, note that I don't want to save this image, I only want to load it into an ImageView and get bitmap drawable from the ImageView later.



This is what I have Implemented:
To launch the camera:



Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if(cameraIntent.resolveActivity(activityWeakReference.get().getPackageManager()) != null){
startActivityForResult(cameraIntent, UPLOAD_PICTURE_CAMERA);
}


Below is onActivityResult(int requestCode, int resultCode, Intent data) invoked when startActivityForResult() is called:



@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && requestCode == UPLOAD_PICTURE_CAMERA) {
try{
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
imageViewphoto.setImageBitmap(imageBitmap);

}catch (Exception e){
Log.e(TAG, Utility.stringify(e));
}
}


The Problem:
The above code works well up to android 7.0, but on Oreo 8.1, the activity closes immediately the Camera is opened so onActivityResult() is not called.



This is all the log I could get:



I/PhoneWindow: isNeedChangeStatusBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@c7a24ee] size: 1
isAPPNeedChangeSBColor pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeStatusBarColor false
I/PhoneWindow: isNeedChangeNaviBarColor taskInfo: [android.app.ActivityManager$RunningTaskInfo@5566d8f] size: 1
I/PhoneWindow: isAPPNeedChange pkgName: com.a3lineng.softwaredev.freedom_app needKeep: false
isNeedChangeNaviBarColor false
generateLayout mNavigationBarColor: ff000000
I/PhoneWindow: generateLayout isLightNavi false, Visibility: 0
I/zygote: Do full code cache collection, code=505KB, data=398KB
I/zygote: After code cache collection, code=495KB, data=332KB
D/BaseActivity: On Pause is called
I/zygote: Do partial code cache collection, code=505KB, data=341KB
I/zygote: After code cache collection, code=505KB, data=341KB
Increasing code cache capacity to 2MB
D/BaseActivity: On Stop is called
Disconnected from the target VM, address: 'localhost:8857', transport: 'socket'


Who is facing the same issue on Oreo?, any advice would be appreciated.







android crash android-camera-intent android-8.1-oreo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 14:23







Otunba Tosyne Joseph

















asked Nov 23 '18 at 13:56









Otunba Tosyne JosephOtunba Tosyne Joseph

268




268













  • Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

    – Anurag Chutani
    Nov 23 '18 at 14:06











  • @AnuragChutani, do you mean Camera permissions?

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:15











  • Any crash log ?

    – Benjamin
    Nov 23 '18 at 14:15











  • I have edited the question and added the log, that is all the log I could get

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:22





















  • Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

    – Anurag Chutani
    Nov 23 '18 at 14:06











  • @AnuragChutani, do you mean Camera permissions?

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:15











  • Any crash log ?

    – Benjamin
    Nov 23 '18 at 14:15











  • I have edited the question and added the log, that is all the log I could get

    – Otunba Tosyne Joseph
    Nov 23 '18 at 14:22



















Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

– Anurag Chutani
Nov 23 '18 at 14:06





Check required permission for MediaStore.ACTION_IMAGE_CAPTURE

– Anurag Chutani
Nov 23 '18 at 14:06













@AnuragChutani, do you mean Camera permissions?

– Otunba Tosyne Joseph
Nov 23 '18 at 14:15





@AnuragChutani, do you mean Camera permissions?

– Otunba Tosyne Joseph
Nov 23 '18 at 14:15













Any crash log ?

– Benjamin
Nov 23 '18 at 14:15





Any crash log ?

– Benjamin
Nov 23 '18 at 14:15













I have edited the question and added the log, that is all the log I could get

– Otunba Tosyne Joseph
Nov 23 '18 at 14:22







I have edited the question and added the log, that is all the log I could get

– Otunba Tosyne Joseph
Nov 23 '18 at 14:22














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448031%2fandroid-8-1-closes-activity-when-startactivityforresult-is-called%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53448031%2fandroid-8-1-closes-activity-when-startactivityforresult-is-called%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...