question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"capture.onResume()" not able to start camera preview.

See original GitHub issue

Hi @rkistner

If first time i allowed the camera permission, and in between if i deny the camera permission from “App info”, and if again i will start scanner and again allow the permission then the camera preview does not start immediately only red strip blinking; for camera preview i have to start my activity again (and i’m not finishing my activity on positive button click because i have manual barcode entry option too). Means user want it immediately start the camera preview as soon permission allowed, and there is a possibility that user may deny the camera permission anytime.

      @Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults)
{
    if(requestCode == cameraPermissionReqCode)
    {
        if(grantResults.length > 0 && grantResults[0] == 0)
        {
            capture.onResume();
        }
        else
        {
           displayFrameworkBugMessageAndExit();
        }
    }

}


private void displayFrameworkBugMessageAndExit()
{
    Utils.displayInfoDialog(this, getString(R.string.scanner_error_title), getString(R.string.scanner_error_message), new DialogOnDoneCallback()
    {
        @Override
        public void OnDone(Object onDone)
        {
        }
    }, true);
}

Please look into this…Thanks in advance.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Bajranghudda1commented, Dec 13, 2016

@rkistner @meierjan @cnworks Hi there i got its solution,

Its because, what we were doing capture.onResume(); we were calling on onResume() of activity and if permission is granted, its okay for library to initialize all camera instance but if the camera instance is not created (if user deny the permission) and we are trying to call capture.onPause(); on our activity’s onPause(). So that time there is nothing to pause. Thats it. So make sure before to call capture.onPause() that, Is camera is already initialized or not.

0reactions
Bajranghudda1commented, Dec 14, 2016

@rkistner @meierjan @cnworks Hi there i got its solution,

Its because, what we were doing capture.onResume(); we were calling on onResume() of activity and if permission is granted, its okay for library to initialize all camera instance but if the camera instance is not created (if user deny the permission) and we are trying to call capture.onPause(); on our activity’s onPause(). So that time there is nothing to pause. Thats it. So make sure before to call capture.onPause() that, Is camera is already initialized or not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera Preview not visible after App Resumes - Stack Overflow
You create a CameraPreview only onCreate() of your Activity. But the camera instance is released onPause(), and a new one is opened onResume()....
Read more >
Camera preview disappears after Fragment onPause ...
STEPS TO REPRODUCE: 1. Build and launch app attached 2. Swipe view pager right then left 3. Preview is gone. OBSERVED RESULTS: No...
Read more >
Introduction to activities - Android Developers
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial...
Read more >
Android Camera Preview App: Camera vs. Camera2
Create a new project with Empty Activity template. ... I want to make the code as simple as possible, so there is no...
Read more >
CameraX Camera Leaks - Google Groups
if you need to change the orientation of imageAnalysis while onResume(), you can directly call imageAnalysis.setTargetRotation() to the existing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found