This is my first post here and I've got a big problem concerning the access of local file addresses on tablets.
I'd like to load image files in a game by using AJAX to get a JSON file containing URLs of images. My problem is that I dont know if it is possible to get local file addresses directly from the tablet folders using JSON.
Seems like I should use an URL that looks like this "storage/sdcard0/myImage.png." but I'm not sure that it's actually calling the file. Is it ?
I'm using Construct 2 because I'm not a coder, so I'm quite limited as for raw JavaScript programming. Please try not to flood me with code :D
I believe you can, URI can be used for urls and local filepaths:
URI | Android Developer
Related
I want to upload all files of a folder to my PHP page.
That is, If I have several images inside a folder, and I want to upload (HTTP POST) all pictures in the folder to my PHP page, which then gets saved in my web directory by their respective file names.
How can I do that? I know about AsyncTask, but I am beginner in Android programming.
I don't know how to make array or list or loops.
AsyncTask is way too older, I am not saying we should not implement but has to take care of a lot of things if implemented!
Rather go with implementing RxJava based implementation but again since you are new to the android programming, so I would not suggest!
Since you are new to the android programming so we can say it's a long problem to solve. I would suggest you go steps wise steps. Let me give you pointers you would be searching, exploring and building around:
Find the directory in folders and iterate through each files to prepare a list
Two popular ways of uploading images: 1) Convert into Base64 and upload one by one 2) Multipart image upload
Instead of AsyncTask, you may use Retrofit Multipart image upload
I have encountered a strange problem I am unable to debug. An image is uploaded to Onedrive via some code very similar to the given example, and once uploaded, the image is visible in the OneDrive web interface.
http://msdn.microsoft.com/en-us/library/dn659727.aspx
Upon trying to download it, again using code from the example, the following line of code
Bitmap bMap = BitmapFactory.decodeStream(input);
also returns a null value for bMap. I know these files (which I obtain from copying from the Android Clipboard and writing to a file on disk) are valid, b/c I use them in Gridview elements and upload/download them to Dropbox in a similar way.
Is there some kind of jpg re-encoding performed in OneDrive (like RGB->CKMY conversion) what would no longer prevent them from working?
Also, is there some other type of query parameter like "/picture?type=thumbnail" or "/picture?type=normal" that needs to be appended to a file.XXXX OneDrive ID that would prevent any possible conversion?
Is there a way to debug exactly why the BitmapFactory.decodeStream() function fails, like debugging output?
EDIT: So, I came across the following SO post, and figured out this is the same problem I am having.
OneDrive - Wrong size for PNG files
For a certain file, if I download it using the Onedrive SDK and look at the stream length
public void onDownloadCompleted(LiveDownloadOperation operation) {
int length = operation.getContentLength();
}
it reports a size of 2723 bytes, but if I download the file and save it using a desktop web browser, the file is 1837 bytes. Is there something I am missing about reading the size of a stream, or is the API just broken?
This is documented behaviour as per http://msdn.microsoft.com/en-us/library/dn659726.aspx (see the first note under uploading).
You can disable conversion by adding downsize_photo_uploads=false to your query string.
The answer to this question apparently is, there is a bug in the Onedrive SDK. I ended up filing an issue on Github with Microsoft, and it turns out they discovered that with certain types of small images (and potentially PDFs), the actually file size being transmitted back after a download is wrong.
https://github.com/liveservices/LiveSDK-for-Android/issues/37#issuecomment-65457177
It's all just a weird artifact of the way I was testing my app. Since Chrome for Android is the only app I've discovered that lets you copy an image to the clipboard, I was just Google search to find images (tiny thumbnail images in the basic web search results), and copying those to the clipboard. Had I been using larger images, I may never have run across this bug.
Does anyone know what the size limit is of a JSON file in PhoneGap 3.0?
I access an external JSON file to populate a carousel gallery. When the JSON file was like 20KB size everything worked perfect but when I tested with 200KB the app began to lag really bad and if I use a bigger file like 500KB, the app gives an alert than it's unable to access the file. I tried to access the file from the server and from direct file in the app... same result.
So did anyone experience a similar problem or does someone know if there is a better solution to this?
Maybe SQLite ? Or how about using MySQL on the server and only exporting the JSON for the necessary query?
This discussion might help you. What they are saying is to
break the data up into chunks
load each in, and save off to SQLite
Hope this is what you looking for. Cheers!
In my project call to the webservice generates URL of images which is different each time and it is timed which wont work like any other URL. When i click on that URL images gets downloaded in my drives. But i want to save it in my db.
I Have seen this Link and tried with it. But for my auto generated URL type that code wont work. Anyone has idea about how to get to know how to save the webservice auto generated URL in my sqlite?
As i analyzed the problem what i think is you will have two ways doing it
1) Storing the downloaded image inside sqlite and displaying it.
https://stackoverflow.com/questions/11304703/download-an-image-and-store-in-sqlite-in-android-local-db/11305051#11305051
2)or else just do how they have done in this blog
http://www.getablogger.blogspot.in/2008/01/android-download-image-from-server-and.html
may be you might get better way.
ALL THE BEST
I am able to parse html content using HTMLCleaner & able to populate in list view. But extracting image I ma facing problem. while I am able to get images from any web server, i am not able to get same from my local Apache http server.
I want to know the reason & possible solution.
Thanks in advance.
It seems like the phone (emulator?) doesn't have access to your local server.
Use the browser in the phone/emulator and try to access your server just to make sure if it's this problem.
If you have access, print the url and make sure everything is alright.