Another Camera Fix (It's really a workaround) to try

Search This thread

Androguide.fr

Account currently disabled
Jul 21, 2012
2,056
7,236
GB
meettomy.site
That's a really good & simple idea, which actually works, kudos to you man :good:

I'll make a transparent version, with no actionbar nor launcher icon which works without tasker when I have some time.
 
Last edited:
  • Like
Reactions: abbychauhan

Androguide.fr

Account currently disabled
Jul 21, 2012
2,056
7,236
GB
meettomy.site
GLmBRTW.png


Alright, so this fork of the original app does the following:

  • Fully transparent (you can't see it's there when it's running)
  • Runs automatically on boot
  • Notifies you with a Toast ("Fixing camera...")
  • Does not show-up in the recent apps panel
  • Does not block the UI thread (you can for example use the status bar while the app does its thing (5sec), but of course any touch below that will be intercepted by the activity, it's transparent but it's there).
  • You choose if you want a version with a launcher icon (I made it nice & flat so it's bearable to have in your app drawer) or without a launcher icon

The code is available on my github and licensed under the Apache v2 license.
The apks are also hosted at github.


Downloads


Big thanks to @drklaw for the original idea & implementation!
 
Last edited:

abbychauhan

Senior Member
Dec 20, 2013
1,833
1,131
JAIPUR
GLmBRTW.png


Alright, so this fork of the original app does the following:

  • Fully transparent (you can't see it's there when it's running)
  • Runs automatically on boot
  • Notifies you with a Toast ("Fixing camera...")
  • Does not show-up in the recent apps panel
  • Does not block the UI thread (you can for example use the status bar while the app does its thing (5sec), but of course any touch below that will be intercepted by the activity, it's transparent but it's there).
  • You choose if you want a version with a launcher icon (I made it nice & flat so it's bearable to have in your app drawer) or without a launcher icon

The code is available on my github and licensed under the Apache v2 license.
The apks are also hosted at github.


Downloads


Big thanks to @drklaw for the original idea & implementation!


Superb work again man.. Can't thank u guys enough

As i stated earlier -
"Just a suggestion.. Can u make something like "Restart Camera App" or something like that or u can modify this app only as if Camera broken after a day or two so we didn't have to reboot the phone as ur app doesn't fix it once it's broken and v ll have to reboot. By this we just use Restart Camera App and then use ur App and have a perfect camera without a Reboot.
Thanks in Advance"


Sent from my Xperia Z1 using XDA Premium 4 mobile app
 

Androguide.fr

Account currently disabled
Jul 21, 2012
2,056
7,236
GB
meettomy.site
Superb work again man.. Can't thank u guys enough

As i stated earlier -
"Just a suggestion.. Can u make something like "Restart Camera App" or something like that or u can modify this app only as if Camera broken after a day or two so we didn't have to reboot the phone as ur app doesn't fix it once it's broken and v ll have to reboot. By this we just use Restart Camera App and then use ur App and have a perfect camera without a Reboot.
Thanks in Advance"


Sent from my Xperia Z1 using XDA Premium 4 mobile app
The problem is you can't do that.
Even when developing Camera-related apps on a device with fully working camera it's a P.I.T.A because once the Camera object instance hasn't been release()'d properly and you get the dreadful "Cannot connect to the camera" dialog, the only thing that'll fix it is a reboot.

What you could do if you still have the issue after using the device for a couple of days is to set Tasker to reboot your device every night while you're sleeping.
 
  • Like
Reactions: omar300

abbychauhan

Senior Member
Dec 20, 2013
1,833
1,131
JAIPUR
The problem is you can't do that.
Even when developing Camera-related apps on a device with fully working camera it's a P.I.T.A because once the Camera object instance hasn't been release()'d properly and you get the dreadful "Cannot connect to the camera" dialog, the only thing that'll fix it is a reboot.

What you could do if you still have the issue after using the device for a couple of days is to set Tasker to reboot your device every night while you're sleeping.

Ya.. Thanks that's again good workaround solution

Sent from my Micromax A110Q using Tapatalk
 

Juzman

Senior Member
May 4, 2011
2,468
716
Townsville
justynsmith.info
  • Runs automatically on boot
  • Notifies you with a Toast ("Fixing camera...")
  • Does not block the UI thread (you can for example use the status bar while the app does its thing (5sec), but of course any touch below that will be intercepted by the activity, it's transparent but it's there).

I installed the "no icon" version on latest CM11. I don't get any toast notification (even though "Show Notification" is ticked), and nothing in status bar about it running on startup (even waited up to 15 seconds).

Checked in "Privacy Guard", and it says "Auto start - never used"
 

llewelld

Senior Member
Jan 24, 2011
229
39
I've installed the apk above (with icon), but still in the last 24 hours had one instance of the camera error.

Have checked and the z1 camera fix is definitely set to auto start on boot (checked with a startup manager).. so not sure if this is not working at all..

Im on PA 4.4 beta1 on Z1..

Should I try using tasker to start it as well? is it possible that something in kitkat stops it starting automatically even though its in startup items? not really sure how I can tell if it actually starts on bootup?
 

->---

Senior Member
Nov 10, 2012
429
82
Wien
I've installed the apk above (with icon), but still in the last 24 hours had one instance of the camera error.

Have checked and the z1 camera fix is definitely set to auto start on boot (checked with a startup manager).. so not sure if this is not working at all..

Im on PA 4.4 beta1 on Z1..

Should I try using tasker to start it as well? is it possible that something in kitkat stops it starting automatically even though its in startup items? not really sure how I can tell if it actually starts on bootup?

You will see a small message directly after logging in when the app is started. Do you use an app which is activating Kernel SamePage Merging KSM?
 

llewelld

Senior Member
Jan 24, 2011
229
39
You will see a small message directly after logging in when the app is started. Do you use an app which is activating Kernel SamePage Merging KSM?

Thanks, running pimped kernel but ksm is off. Not sure what happened, but have been flogging the camera and not had it happen again.. think it might have been a startup manager interfering but seems rock solid now.. Thanks!
 

moheysaleh

Member
Dec 26, 2010
37
16
Cairo, Egypt.
GLmBRTW.png


Alright, so this fork of the original app does the following:

  • Fully transparent (you can't see it's there when it's running)
  • Runs automatically on boot
  • Notifies you with a Toast ("Fixing camera...")
  • Does not show-up in the recent apps panel
  • Does not block the UI thread (you can for example use the status bar while the app does its thing (5sec), but of course any touch below that will be intercepted by the activity, it's transparent but it's there).
  • You choose if you want a version with a launcher icon (I made it nice & flat so it's bearable to have in your app drawer) or without a launcher icon

The code is available on my github and licensed under the Apache v2 license.
The apks are also hosted at github.


Downloads


Big thanks to @drklaw for the original idea & implementation!
sorry if it seems like a stupid question, but does this fix work for LB unrooted stock 14.4.a.0.133 with stock kernel?
I already installed the apk with icon and when I restart the phone I see a toast saying "fixing camera". so does this mean it's working or do I need to root or something?

Thanks a lot.
 

ploopower79

Senior Member
Oct 17, 2012
265
113
Houston
sorry if it seems like a stupid question, but does this fix work for LB unrooted stock 14.4.a.0.133 with stock kernel?
I already installed the apk with icon and when I restart the phone I see a toast saying "fixing camera". so does this mean it's working or do I need to root or something?

Thanks a lot.

This was meant for AOSP roms not stock :) it won't do anything for stock Sony firmware
 

Top Liked Posts

  • There are no posts matching your filters.
  • 52
    GLmBRTW.png


    Alright, so this fork of the original app does the following:

    • Fully transparent (you can't see it's there when it's running)
    • Runs automatically on boot
    • Notifies you with a Toast ("Fixing camera...")
    • Does not show-up in the recent apps panel
    • Does not block the UI thread (you can for example use the status bar while the app does its thing (5sec), but of course any touch below that will be intercepted by the activity, it's transparent but it's there).
    • You choose if you want a version with a launcher icon (I made it nice & flat so it's bearable to have in your app drawer) or without a launcher icon

    The code is available on my github and licensed under the Apache v2 license.
    The apks are also hosted at github.


    Downloads


    Big thanks to @drklaw for the original idea & implementation!
    22
    Short version:

    1. Download the apk posted below and install it.
    2. Set the app to run on boot using the method of your choice (I use Tasker).

    Updated app link:
    http://xdaforums.com/showthread.php?p=52696903
    20
    Long version:

    Hello there,

    This is basically a call for a bit of dev help for a potential workaround I think I may have stumbled upon for fixing the annoying hanging camera issue we seem to have on a bunch of the CM/AOSP based roms. The symptoms of the issue are:

    1. Reboot phone
    2. Open any camera app - there's a frozen frame for a moment then it either
    a. works normally
    b. freezes and camera apps then "cannot connect to camera" until you reboot and try again.

    The issue I was seeing on my phone (running the awesome SlimKat ROM) was that sometimes it would end up at 2a, and sometimes at 2b. I could not see any pattern, rhyme, or reason for it. Until...

    I opened the ROM's camera app (set to store on my SD card) with my SD card removed. This caused the camera app to crash before showing any camera preview. I then noticed that once I put the SD card back in the camera app would open and work perfectly and immediately. No freezing at all. I have replicated about 20 times successfully, with no instances of 2b.

    That made me think. I've done some Android head tracking coding in the past and worked with camera previews and I know that to get a camera preview running, you first open the camera object then start the preview. Since normally, sometimes the situation would be 2a and sometimes 2b, that made me think that there might be a race condition happening between the "camera open" step and the "show preview" step.

    So I made a simple app to open the camera, wait 5 seconds, and close, without showing any preview. I set this app to run on boot-up using Tasker. (This is meant to replace the manual SD card trick I was using, outlined above.)

    I'm sharing this with the hope that the ROM developers, who are far more skilled than I, might use this information. I attached my apk (a better one is posted later in this thread with a link to that post in the next post), and I'll give you the code (again, updated later). I hope you can use it to confirm or reject my findings or even do a better job integrating it into your ROM then I did with my boot-up hack.

    Thanks!

    Code:
    import android.graphics.SurfaceTexture;
    import android.hardware.Camera;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.TextureView;
    import android.view.TextureView.SurfaceTextureListener;
    
    public class MainActivity extends Activity implements SurfaceTextureListener{
    
        private Camera mCamera;
        private TextureView mTextureView;
        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            
            mTextureView = new TextureView(this);
            mTextureView.setSurfaceTextureListener(this);
    
            setContentView(mTextureView);
        }
    
        @Override
        public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
            mCamera = Camera.open();
                 
            try {
    Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
            mCamera.release();        
                            
            android.os.Process.killProcess(android.os.Process.myPid());
        }
    
        @Override
        public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
            // Ignored, the Camera does all the work for us
        }
    
        @Override
        public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
            mCamera.stopPreview();
            mCamera.release();
            return true;
        }
    
        @Override
        public void onSurfaceTextureUpdated(SurfaceTexture surface) {
            // Update your view here!
        }
    }
    2
    Ya it will do but u ll have to do this by ur own on as soon as ur device boots up because if u don't do it and opens camera app and if it showed Can't connect the Camera Error and then after that if u press this app then it won't be able to help u.. It will crash, happened with me.

    Sent from my Xperia Z1 using XDA Premium 4 mobile app

    Yes. This workaround is designed to prevent the camera from breaking when opening for the first time since reboot. It doesn't fix it once it's broken. I doubt anything could do that.