let me address my issue here.
i'm using an Intent to grab an image from the camera file by passing a file along the Intent to return it, however in my tests in the Samsung Galaxy S5, if the image was taken normally the image will return, but lets say if Samsung tries to handle low light and do its "so called hard working" the application will crash. i'v tried storing the fileName in onSaveInstanceState and retreiving it in onRestoreInstanceState this prevent the application from crashing, but however it recreates my Activity which below it there is another Activity which has BroadcastReceiver that is been destroyed along when the Activity recreated, is there any workaround to tell Samsung to take the image without its crappy features to prevent this scenario from happening?
Edit
with test with only sending the Intent without passing a Uri file with it, it still if it handles low lights, the application will crash.
While developing our Cordova app on Android on a Samsung S5, I've noticed the same issues – in regular mode, the Samsung camera app appears to use less memory, so the Android garbage collector doesn't kill our app. However, in the low-light mode you're describing, the Android garbage collector kills our app in the background.
The Cordova camera plugin doesn't support the Android lifecycle, so I've had to fork it, and store the imageUri (and some other settings) to a Preference in order to retrieve it again once the app restarts.
I think you'll need to put a Debug.waitForDebugger() statement in your onActivityResult method, so that when your app restarts you can connect the debugger and step through your code that processes the result. My guess is that you're referencing a variable that isn't available because of the loss of state.
Related
I am kinda new to App development and working on my first app, which is taking a burst mode of pictures with the current gps coordinates attached to each picture.
I was trying this app with my Sony Xperia L with JellyBean 4.2.2 and it takes burst shots of any number I have input. I tried to run my App in 4.4.4 and it runs basically, open the number of cameras, but i click to 'take' picture, my app crashes.
NOTE:
Behind this take picture button is kinda loads of work loadI know it sounds stupid to put up all things in main activity, but i dont know how to take off the load.
The fact is its running on 4.2.2 as expected (with many errors in LOGCAT but still running cool) and it crashes when i click 'Snap' in 4.4.4.
in main activity, I am taking jpeg PictureCallBacks and put up the gps listener, pushing to make a photofile with the EXIF DATA embedded and all in MAIN ACTIVITY. here is the picture
You are not allowed to use the android.intent.action.MEDIA_MOUNTED broadcast anymore on Android 4.4, it's protected. Try to use ACTION_MEDIA_SCANNER_SCAN_FILE instead.
See this question, or also this one.
I have a simple drawing app. I have an option to open any image on gallery and draw on it. I am calling gallery intent and getting image from there. This process is working on most of the mobiles. I got complaint from few users that it crashes when they try to open an image. I am not sure why it is working on most of the mobiles and failing to do so in some. What can be the probable issue? And how to debug such issues when it is not crashing on most of the phones and I dont have the phones, where it is crashing, to test on.
There is one more scenario where it is crashing, not crashing exactly, but restarting. When I am calling a sub-activity and returning from there , it restarts on some mobiles. It keeps the data coming from sub-activity but restarts my app (My drawing is lost). What could be the probable cause of this?
Since I dont have the mobiles where it is crashing , it is very hard to test such things.
I have application that opens native camera app and get the captured picture.
I have seen that when my application open native camera application it kills all background running applications(including my application).
This issue is also tested in other flow like : I have opened 3-4 other applications. After that I have opened native camera application directly from the home screen. In this case also it kills all the previously opened application.
I would like to have background app remains opens. Can anybody help me here.
I have tested same scenario with Samsung Galaxy ACE and HTC Desire HD. It's working fine.
Device configuration :
Motorola Droid 3 , Android version : 2.3.4
Yes got it. I have found the solution for it. My problem was like when I open Motorola Droid 3 camera application , it closes all the background running applications. After searching through blogs and apply some logic and found that it was Native camera issue.
So for the solution, I have saved my application state to bundle using method of
protected void onSaveInstanceState(Bundle outState)
and retrieve saved state from onCreate method again and it works. Now my application does not crash. But one more problem here is like whatever image I have captured from the native camera is not displayed to my screen because it is alreaded restarted so onActivityResult method will not be called.
To solve this issue we have to clear the data of native camera app and have to forced stop it once. After that I open native camera app from my application and it works for 2-3 times and again stops working. Again I clear data and force stop native camera apps and it works.
Other solution to this is I have installed Camera360 application and it works fine for me and no need to use default camera application.
I know this is again a work around but if anybody can give me other better solution then it's fine.
Enjoy.
I have been seeing errors come back from my application that it's force closing after the system stop's it and the user bring it back to the front at a later time.
I have some idea's as to what is causing this but I would like to be able to reproduce this error before attempting to fix it.
Does anyone know a way to get the android system to behave like it needs the memory my application is using and close it so I can easily and continually reproduce this error?
Using the Dev Tools app on your emulator, you can have the OS destroy an application as soon as it's stopped.
From the documentation:
Immediately destroy activities
Tells the system to destroy an activity as soon as it is stopped (as if Android had to reclaim memory). This is very useful for
testing the onSaveInstanceState(Bundle) / onCreate(android.os.Bundle)
code path, which would otherwise be difficult to force. Choosing this
option will probably reveal a number of problems in your application
due to not saving state. For more information about saving an
activity's state, see the Activities document.
You can find this under Development Settings once you're in the Dev Tools app. So, when running your application, you could just switch to another application (like clicking on the emulator's hard phone button), and return to yours to test the destroy/create process.
If you are using Eclipse or DDMS you can select your app in the process list and hit the stop button. This should close your app.
In my app when i press home button and open the app from menu or shortcut it returns in the same screen but the pid of the process is killed.
BUT
if i hold home button and choose my app from there it will resume normally
This problem is not happenig in all devices 2.2.1 and 2.3.5 samsung galaxy Ace
if is solved again ( i doubt i lost many hours searcing) please link the answer
Thanks in advance
EDIT
In 2.3.6 Samsung Nexus S doesn't happen.
You shouldn't worry about that. The whole Android ecosystem is built around the concept of never terminating your application yourself, and letting the OS handle that aspect of things, and it's working very well if your app is written following the good practices.
Make good use of the Activities lifecycle methods (onPause, onResume, onStop, etc.), and everything will work smoothly, whether your app has been effectively terminated or kept in the background by Android.