In my app, I have to show the photos captured in a grid view and let user choose the one that they want to mess with. I am querying MediaStore.Images.Thumbnails to get the list of thumbnails to display.
The app works fine --well most of the time. However, when the user puts the app in the background and takes photo and launches the app again, it does not display the new photo. The reason is that I am not reloading the thumbnails onResume of my activity.
I do not want to refresh every time onResume because, most of the time it is unnecessary query to file system. My question is, is there a broadcast message or notification that I can register to get notified when a photo is taken from the camera even when my app is in background?
BTW: With still a lot of gingerbread phones around, the requirement is that it should work on 2.3.3 onwards.
Related
I have an app where I should fill data on some edittexts or spinners. After that I have some buttons where I should take some pictures, sometimes there's 2 or 3 pictures. Im using a Camera Intent.
The problem is that SOMETIMES just in SOME PHONES, when the app comesback from Camera app it deletes all data filled on the views, and it deletes the pictures already taken. So it crush the activity.
I'm pretty sure its not the orientation, since IM using this on the manifest.
<activity
android:name=".MainActivity"
android:configChanges="screenLayout|orientation|screenSize">
I have nothing on the error log. One solution is when I delete data from Google Play Services or I unistall it and reinstall again. This fix the problem for sometime and then it happens again.
I dont know what else could it be. On the activity Im using Camera and Im accesing User location.
Camera app takes a lot of memory and on low-end devices with less memory system might kill your app to free some memory.
android:configChanges is more of a hack rather than a correct solution, it does not prevent a case as described above.
You should implement correctly activity life time cycle functions, by saving instance state in onSaveInstanceState and recreating it in onCreate. There is no other way around.
To test such cases, go to developer settings and disable applications in background. This way each time you will click on home button of your device, your app will be killed, and going back to it it will be recreated.
Alright so I'm trying to achieve something that shouldn't be that difficult but for some reason or another it is. So I have an app that goes through a setup process where it asks for your name and then two ID numbers and all this is saved in shared preferences and no matter if a reboot or force close the app the data is kept. Third step in the setup process includes getting a picture from the user, and I have successfully gotten it to show up once but it doesn't stick after a reboot or force close. So my question is what code do I need to open the gallery picker intent so the user can choose a photo, save that photo, write that Uri to the photo in a string, and then proceed to enter it into a SharedPreference so it sticks across reboot/ force close. I had the code working but it wouldn't save the Uri in the correct manner so therefore it wouldn't load. But I scraped all this code in hopes someone can give me a more direct answer. Thanks!
Most Uri values are transient and are not guaranteed to be usable minutes after you get them, let alone forever.
Your choices are:
If your minSdkVersion is 19+, use ACTION_OPEN_DOCUMENT to pick the image. The Storage Access Framework has an option for persistent Uri permissions, with a side effect of having a more durable Uri. Even then, though, since the user might get rid of the image, you cannot assume that you will have access to it forever.
Copy the image into your own app and use your local copy.
Is there any way to determine when screenshot is taken in android device. Basically, I have an activity which should show sharing options when user takes a screenshot. Is there any way or flag to determine?
Suppose I want to start an app to run in background as soon as an event occurs in the phone.
For example:-
When I open my gallery I may want to automatically start my app which monitors my file browsing and prepares database for most recent documents, most listened song, etc and is automatically closed when I exit my gallery folder.
Whenever I open my internet browser I might want to start my app in background, which monitors how many times I visited a particular site and it automatically closes when I close the browser.
I don't think this is possible, and i'm not talking about remote launch app, but capture events of other apps like Gallery or Browser.
If this are only hipotetic examples, you should show a real examples because i think collect this type of data will be more painful problem than trigger app on an event due a lot of security reasons.
A User takes pictures using camera in his device. My application should keep track of how many photos captured by the user.
I don't want my application to launch any default camera. I want to get count incremented for clicked photos by the user with his device camera.
Since devices having soft button camera not works with CAMERA_BUTTON intent, so is there any other way to get count.
my application should keep track of how many photos captured by the user
In general, that is impossible. You have no ability to spy on arbitrary actions of other applications.
The closest thing is what julian suggested -- use a FileObserver to monitor Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM). However, not all camera applications will store their pictures there.