Adding pictures to the Gallery - Android - android

I have an activity that takes a photo with the camera, and then adds it to its proper folder (in this case /DCIM/Camera). But then when you exit the app and load up the Android gallery...it's not there. I was doing some playing around and noticed it only appears there when after restarting the phone. I'm not sure the reason behind this (maybe it has to create the thumbnail?)...is there any way around this? I want it to show up right away.
Thanks!

You need to run the MediaScanner with the path of the newly added photo. Will show up in the library then. API Level 8 has a convenient function for this called scanFile.
Details at http://developer.android.com/reference/android/media/MediaScannerConnection.html

Select "Dev Tools" from the Apps screen, the select "Media Scanner" (or "Media Provider" in newer versions of Android) to get the emulator to recognize the files so they would be displayed in the Media Gallery.
Pls mark the ans as correct if you think it resolved your issue. tnks :)

Related

The Android SDK could not be loaded Processing

When I try to download the Android SDK when Processing doesn't find it, at 30%, it says "The Android SDK could not be loaded, Android mode will be turned off"
I'm using Windows 10 home edition, Processing 3.3.6, Processing-Android 4
https://github.com/processing/processing-android/issues/421
Install Android Studio, open it
click configure, click SDK Manager, checkmark the box labeled Android 8.0 (Oreo), apply, install, copy the file path at the top, apply.
Open processing, in android mode, select Locate SDK Manually, paste.
It is quite simple! Download Android Studio from https://developer.android.com/studio, install it, click the "SDK Manager" button on the top right corner, as you can see in this image. Then download the version of the SDK that you want...make sure to download the correct version - the one mentioned by the error dialog from the PDE (Processing Development Environment/ Processing IDE/program/app). After it has downloaded, select the checkbox next to it, and copy the path for it, as shown here. Launch the PDE in Android mode, and when it asks you for the path, Select Locate SDK Path manually and paste the path there. It should work now.
On Windows, at least, You may want to un-hide the AppData folder, I had to, though I'm sure it's not a requirement, if it has worked out for you so far, skip this step!
To unhide the folder, in the Windows Explorer, go to C:\Users\<Username>\, select the AppData folder, and unhide it..
(Enable "Hidden items" under "View" first! look at this image for reference)
..by going to View > Hide selected items, as shown in this image and selecting "Apply changes to this folder only". THEN the PDE may be able to see it. YOU MAY WANT TO HIDE THE FOLDER AFTER DOING THIS! It is a quite important system folder, though I'm sure many people access a lot, it still needs security; ...it's better for you, I guess.

in an AVD I can't seem to get the sdcard to work

I've created an AVD, got it to work fine except when I try to add an sdcard to it it doesn't work. I don't get an error message or anything but when I push files onto it, they don't show in the gallery. Someone on a different post suggested just downloading a pic off the internet instead of trying to push one on so I tried that and got an error message that said
"No SD card
an SD card is required to download 01.jpg"
I've tried every solution I could find including going through the CMD and remounting the sdcard. Nothing worked. Any ideas? Why does it say "No SD card" when I already added it to the AVD? Why does it still say that after I've remounted it, which apparently is the only way to make it so I can push files onto it. That's how I got a different error message to go away! This thing has been one major headache after another! Once I solve or find a work-around for one problem another pops up almost instantly!!
Same problem i also faced but i got solution with following steps
1) AT the time of creating new AVD you have to give value in SD Card.
2) After starting the AVD insert the image that you want in AVD.
3) Next restart the AVD
Note : Enter SD Card value from 10 MB onwards if you give more it may not start AVD it will keep showing android.
this solution is worked for me, hope this will helps you.

Android: How to open a file from inside your application

I've done my fair share of searching for tutorials and guides online, but the only stuff I have found is from 2007 and out of date.
I wanted to know how to open a file from within my current application. For instance, if I click a "Browse" button, it will start another activity of a default file browser on the device (I don't have to implement my own, right?). Obviously I would need it to return the file so I could parse through it as I pleased.
I figured it would be some for of Intent binded to the the button, but I'm now sure.
Bad news - there is not a native "file selector". Good news - this guy made one so you don't have to.
Use Environment.getExternalStorageDirectory() instead of hard-coding the directory path to the SD card. There also seems to be a problem with getting the exact SD card directory using Android 3.0 and 3.1. I have a test app that reads and writes fine in Android 2.3.3 but the same piece of code doesn't work anymore (see https://stackoverflow.com/questions/6545478/android-3-1-sd-card-emulation).

How to put a wallpaper inside an apk file?

I'm planning to release a nice clock widget and I'd like to include a pretty wallpaper with it (want to do this because previously got some comments like "can i get the matching wallpaper? ;)")
So I tried to google on how to put some image file inside apk so that it would appear in wallpapers selection list after installation. I mean the list which appears when doing Home=>Menu=>Wallpaper=>Wallpaper Gallery or Pictures - whatever.
So far didn't find any hints, so decided to try to ask here.
Any hints on how to do that?
You could package the wallpaper in res/raw, and then when your app fires up for the first time, attempt to copy it to the sdcard directory /media/pictures.
You should be using methods such as getExternalStorageDirectory or getExternalStoragePublicDirectory (depending on the API level) to open the file.
http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

Camera pics not appearing in Gallery app

When I take pictures using android.hardware.camera and I save them to the following location /sdcard/dcim/camera/ they don't appear when I launch the gallery. Is there a process for getting them to show up in the gallery that I missed?
I can see my images using a file explorer and know they have been saved.
You need to run MediaScanner on the type of media that you have saved to make your changes(SDcard writes) transparent throughout the system.
MediaScanner is bundled with devTools package so you can either run it manually or you can also do it via Java code(right after the write to SDcard op). Google "MediaScanner" you will find plenty of examples.
Hope that helps.

Categories

Resources