Android :: MultiPart Post File Not Working On 2.1 SDK
Apr 27, 2010
I'm working on a sample application that does FileUpload using Multipart post, with Andorid 1.6 SDK the application works as expected but with 2.1 there is an issue basically the application does not execute and stays stale as soon as the upload process has started.
Basically, i use "java.net.URLConnection" for establishing connectivity with the server. Is there any changes made with the core Java API's in Android SDK 2.1 that causes this issue.
View 2 Replies
Jul 13, 2009
I have a class that implements a multipart file upload. The code works on every java client I've tried it on but does not work on Android, *and* it's the only HTTP request code in my Android app that doesn't play nice with my back end service. I've looked through the posts to see if other are having similar issues but so far have only found posts like this http://groups.google.com/group/android-developers/msg/c4b0270153d194d9 , which are nearly the same as mine. T The symtoms I'm seeing are that the connection responseCode is "-1" & no entries show up in the Apache access or error logs. It seems as if the request is never making it off of the android platform. The code gets right through the connection writes in the debugger with no errors, but hangs on the connection read, times out and then returns with -1. Behavior is same for real phone and emulator. As I mentioned, this code is in use elsewhere and works fine.
Does anyone know of any gotchas one needs to look out for when posting a multipart file in Android? Anything about doing a POST or a POST w/ data on Android?
I'm including the code/class below so you can see what I'm up to.
CODE:.................
View 2 Replies
View Related
Jan 7, 2010
I'm trying to do something I thought would be relatively simple: Upload an image to a server with the Android SDK. I'm found a lot of example code:
http://groups.google.com/group/android-developers/browse_thread/thread/f9e17bbaf50c5fc/46145fcacd450e48
[url]
But neither work for me. The confusion I keep running into is what is really needed to make a multipart request. What is the simplest way to have a multipart upload (with an image) for Android?
View 1 Replies
View Related
Sep 11, 2010
I would like to develop an application that uploads an image and some text data about that image.
To do that, I am trying to create a HTTP Multipart Post, as follows:
code:..........
My doubt is: how can I extract those values in the server? I would like to develop a Servlet to receive and process the post requests. In this Servlet I would need to extract these values in th request. Can you help me? Do you have any sample of server to answer the android multipart requests?
View 2 Replies
View Related
Sep 15, 2010
I am writing an application to upload a file from Android phone to a web server. I have tried the example from:
http://www.anddev.org/novice-tutorials-f8/doing-http-post-with-android
But it will only work for SDK 1.0 (why? Not Sure?).Can this be done for Android 2.1? Or is there any other method to load a file from Android to a webserver?
View 5 Replies
View Related
Aug 14, 2010
Trying to figure what's wrong with my codings. I followed a blog post from here. I managed to get the codes to actually upload the file to a PHP web service. However, for some reason although I've set explicitly the MIME type for the file, PHP shows that the MIME is just a blank string and therefore rejected.
View 2 Replies
View Related
Jul 9, 2010
I am developing an Android app which enables the user to upload a file to services like Twitpic and others.
The POST upload is done without any external libraries and works just fine. My only problem is, that I can't grab any progress because all the uploading is done when I receive the response, not while writing the bytes into the outputstream.
View 2 Replies
View Related
May 14, 2010
has anyone noticed that post OTA the speed dial no longer works? i had speed dials set up before the update and they worked fine. after the update whenever i try to set speed dials they just don't stick. everything seems to work fine, but after i hit save they just don't register.
View 6 Replies
View Related
Sep 25, 2010
My Django view generates a PDF via pycairo in response to a POST (I'm not redirecting in response to the POST). When I POST using desktop browsers I can save and/or view the PDF using Adobe Reader or Document Viewer. However, when I POST via my android browsers the Adobe PDF Reader and the ThinkFree viewers both report the file as corrupted.
Looking in the logfiles on my appserver both Android browsers are sending a POST followed immediately by a GET for the same page:
CODE:.....
When I look at the file saved to the phone it is the HTML of the GET request.
Here's a skeleton of the view:
CODE:...........................
So I'm wondering what could be causing the android browsers to perform the GET?
View 1 Replies
View Related
Jan 29, 2009
I am trying to send a multipart SMS using the following code. While the SMS is being split into multiple parts and sent across, in the receiver, I am seeing some junk characters (as if i am reading a binary file). Obviously, I am not doing something correct.
CODE:....................
View 2 Replies
View Related
Jun 9, 2009
HttpClient 4 doesn't have that included anymore. The upstream project didn't integrate it from the 3.x client. I had to do exactly the same today. Basically I solved it by including some additional jars: mime4j httpmime This question was already on the list and there's some better explanation: http://groups.google.com/group/android-developers/msg/1ea124b384da9dc2 -- Urs My problem is that while i know what i have to include, i can't find a sensible download link for httpmime. the page points back to httpcore for downloads, but of course it's not in there any more (i checked). i was up for compiling it, but the source link takes me to the javadoc! something is definitely screwed up.
View 14 Replies
View Related
Jun 2, 2009
I'm trying to do multipart form upload using the 4.x httpclient on android. all the 4.x code samples I'm seeing use org.apache.http.entity.mime.MultipartEntity, but I'm running into a roadblock trying to find it. It's supposed to be in the httpmime project, but the download link for that project leads me back to httpcore, and the httpcore download doesn't contain that class. anyone else get multi part form upload to work?
View 2 Replies
View Related
Oct 30, 2010
Post your PingChat ID here lets enjoy together.My ID : talktoanil
View 3 Replies
View Related
Jul 14, 2010
As described in this answer you cannot grab a progress of a multipart/form POST upload in Android using only the Android SDK, because there is an issue with the stream buffering when using HttpURLConnection which will be fixed post Froyo (see http://code.google.com/p/android/issues/detail?id=3164#c6).
Since the Apache HttpClient 3.1 was removed from the SDK quite early and the new HttpClient, which is now part of the SDK, wasn't adopted completely (it misses multipart capabilities) you can add the missing parts (specifically apache-mime4j-0.6.jar and httpmime-4.0.1.jar) to perform a multipart/form-data upload AND grab the progress of the upload (also described in the answer mentioned above).
Now, the reason why I open a new question is, that doing as described leads to an enormous growth of the installed app size (in my case from 170kb to 732kb).
So, the question is: Is there any other way to perform a multipart/form-data upload and grab the upload progress without increasing the app size that much? Are there any other libraries one can use or is there any other alternative way, not mentioned here?
View 1 Replies
View Related
Jul 29, 2010
This is my code.
I got Http 400 error.
CODE:...................
View 2 Replies
View Related
Oct 12, 2010
As part of my Android app, I'd like to upload bitmaps to be remotely stored. I have simple HTTP GET and POST communication working perfectly, but documentation on how to do a multipart POST seems to be as rare as unicorns.
Furthermore, I'd like to transmit the image directly from memory, instead of working with a file. In the example code below, I'm getting a byte array from a file to be used later on with HttpClient and MultipartEntity.
CODE:..............
This all seems fairly clear to me, except that I can't for the life of me find out where to get this ByteArrayPartSource. I have linked to the httpclient and httpmime JAR files, but no dice. I hear that the package structure changed drastically between HttpClient 3.x and 4.x.
Is anyone using this ByteArrayPartSource in Android, and how did they import it?
After digging around in the documentation and scouring the Internet, I came up with something that fit my needs. To make a multipart request such as a form POST, the following code did the trick for me:
CODE:.....
The HTTPMultipartMode.BROWSER_COMPATIBLE bit is very important.
View 1 Replies
View Related
May 10, 2009
In response to a request over here: http://bit.ly/E1Qqm
This is some sample code for uploading an image to the web, as part of a multipart message. It assumes that the photo is stored on the SD card as "photo.jpg". You'll need to download and add a couple of jar files to the project's built path - commons-httpclient.jar and httpcomponents-client-4.0-alpha4.
It is working on my device. However (big caveats here) - it's much slower than I would like, and much slower than other applications I've installed that upload photos. It also feels hacky - e.g. the way the background thread communicates problems with the upload to the main thread using variables. I'm sure there must be a neater way to do it.
If you figure out a way to improve the code,
code:............
View 5 Replies
View Related
Aug 24, 2010
As per this post, An idea for great battery life
Could someone with good battery life on a Galaxy S post their batterstats.bin file?
I'd like to try this fix and not sure if the batterystats file would work from the other thread since its a different phone.
View 1 Replies
View Related
Jul 15, 2010
I took an android project and imported it in eclipse. in properties->android section it is showing platform 1.6 and API level 4. I have downloaded Android 2.2. Now when i try to make some changes in the source code and make an .apk file and try to install on my android device the device shows an error : Application not installed. the project is not showing any error but it is showing a warning : Attribute minSdkVersion (3) is lower than the project target API level (4) in manifest file. the person who gave me th eproject i asked him to mail his .apk file to me and that .apk file is running perfectly on the device.
View 1 Replies
View Related
Apr 3, 2010
My problem is that I try to upload an image and some text values to an rails server, and the text values end up as files, insted of just param values.
How the post looks on the server
CODE:..........
Part of the android code
CODE:..................
View 1 Replies
View Related
Jul 23, 2010
is there any API or any procedure to make the directories of android Pvt. ? i.e when i want to secure some data from other users i can make that directory password enabled.. there are so many folder locks available in android market but i want to know the exact working of that.. pls do reply with code and procedure.
View 4 Replies
View Related
Oct 22, 2010
I am new to Android Development. I want to rename the file f1 with the file f2. For this I used the following code but it didn't work there
File f1=new File("myFirstFile");
File f2=new File ("mySecondFile");
boolean renameSuccess=f1.renameTo(f2);
Log.d("Rename Success value :",renameSuccess); //but it returns the false value.
View 2 Replies
View Related
Jul 29, 2010
I am trying to download an Android APK file that is output by a php page. I have the following and it works on firefox but not on the phone. Firefox downloads with an apk extension but has a little firefox icon next to it. The phone downloads the file with a .html extension, why is this?
UPDATE: Full source
function display($tpl = null) {
//SETUP
$appId = JRequest::getInt('id', '0');
$model = &$this->getModel();
$app = $model->getApplication($appId);.................
View 2 Replies
View Related
Jun 2, 2010
First of all let me say that this questions is slightly connected to another question by me. Actually it was created because of that. I have the following code to write a bitmap downloaded from the net to a file in the sd card:
// Get image from url
URL u = new URL(url);
HttpGet httpRequest = new HttpGet(u.toURI());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
InputStream instream = bufHttpEntity.getContent();
Bitmap bmImg = BitmapFactory.decodeStream(instream);
instream.close();
// Write image to a file in sd card
File posterFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Android/data/com.myapp/files/image.jpg");
posterFile.createNewFile();
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(posterFile));
Bitmap mutable = Bitmap.createScaledBitmap(bmImg,bmImg.getWidth(),bmImg.getHeight(),true);
mutable.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
// Launch default viewer for the file
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(posterFile.getAbsolutePath()),"image/*");
((Activity) getContext()).startActivity(intent);
A few notes. I am creating the "mutable" bitmap after seeing someone using it and it seems to work better than without it. And I am using the parse method on the Uri class and not the fromFile because in my code I am calling these in different places and when I am creating the intent I have a string path instead of a file. Now for my problem. The file gets created. The intent launches a dialog asking me to select a viewer. I have 3 viewers installed. The Astro image viewer, the default media gallery (I have a milstone on 2.1 but on the milestone the 2.1 update did not include the 3d gallery so it's the old one) and the 3d gallery from the nexus one (I found the apk in the wild). Now when I launch the 3 viewers the following happen:
Astro image viewer: The activity launches but I see nothing but a black screen.
Media Gallery: I get an exception dialog shown "The application MediaGallery (process com.motorola.gallery) has stoppedunexpectedly. Please try again" with a force close option.
3D gallery: Everything works as it should.
When I try to simply open the file using the Astro file manager (browse to it and simply click) I get the same option dialog but this time things are different:
Astro image viewer: Everything works as it should.
Media Gallery: Everything works as it should.
3D gallery: The activity launches but I see nothing but a black screen.
As you can see everything is a complete mess. I have no idea why this happens but it happens like this every single time. It's not a random bug. Am I missing something when I am creating the intent? Or when I am creating the image file? As noted in the comment here is the part of interest in adb logcat. Also I should note that I changed the way I create the image file. Since I want to create a file that reflects an online file I simply download it instead of creating a Bitmap and then creating the file (this was done because at some point I needed the Bitmap but now I do it the other way around). The problems persist thought and are exactly the same:
I/ActivityManager(18852): Starting
activity: Intent {
act=android.intent.action.VIEW
dat=/sdcard/Android/data/com.myapp/files/image.jpg
typ=image/* flg=0x3800000
cmp=com.motorola.gallery/.ViewImage }
I/ActivityManager(18852): Start proc
com.motorola.gallery:ViewImage for
activity
com.motorola.gallery/.ViewImage:
pid=29187 uid=10017 gids={3003, 1015}
I/dalvikvm(29187): Debugger thread not
active, ignoring DDM send
(t=0x41504e4d l=38)
I/dalvikvm(29187): Debugger thread not
active, ignoring DDM send
(t=0x41504e4d l=64)
I/ActivityManager(18852): Process
com.handcent.nextsms (pid 29174) has died.
I/ViewImage(29187): In View Image
onCreate!
D/AndroidRuntime(29187): Shutting down VM
W/dalvikvm(29187): threadid=3: thread
exiting with uncaught exception
(group=0x4001b170)
E/AndroidRuntime(29187): Uncaught
handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(29187):
java.lang.RuntimeException: Unable to
start activity
ComponentInfo{com.motorola.gallery/com.motorola.gallery.ViewImage}:
java.lang.NullPointerException
E/AndroidRuntime(29187): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
E/AndroidRuntime(29187): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime(29187): at
android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime(29187): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime(29187): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29187): at
android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(29187): at
android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime(29187): at
java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime(29187): at
java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(29187): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime(29187): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime(29187): at
dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(29187): Caused by:
java.lang.NullPointerException
E/AndroidRuntime(29187): at
com.motorola.gallery.ImageManager.allImages(ImageManager.java:5621)
E/AndroidRuntime(29187): at
com.motorola.gallery.ImageManager.getSingleImageListByUri(ImageManager.java:5515)
E/AndroidRuntime(29187): at
com.motorola.gallery.ViewImage.onCreate(ViewImage.java:1801)
E/AndroidRuntime(29187): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(29187): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
E/AndroidRuntime(29187): ... 11 more
View 3 Replies
View Related
Aug 8, 2010
Why does the move files option not work with any file managers i use?
View 5 Replies
View Related
Jul 7, 2010
I've been trying to export it to a jar file but as there is no main method in my app this doesn't work. Can someone tell me how to create this executable? the executable is to run the emulator and app both in computer not at phone!
View 4 Replies
View Related
Feb 26, 2013
I have a message saying "try reconnecting or restarting your device", I try doing it but it never worked Galaxy note 2 android 4.1.2 and stock.
View 2 Replies
View Related
Mar 31, 2014
So I got my own rom. Its a lightly edited version of the stock rom. But while I try to flash it it gives me back a error. I found out through a flash app that the ZIP file is not valid. (and not giving a explanation why not..)
View 2 Replies
View Related
Aug 17, 2010
Android Beginners is no longer working so I have to post this here. Here's is the case scenario that I would like to do, but I've been googling with no luck. There's text info that the user saved on the drive.
1. I want to open up a dialog, for the user with a listing of the file structure
2. The user can then choose where to save the file
3. Then I want to save the file there
Can anyone offer me simple code for step 1,2,3 that I can use?
View 3 Replies
View Related
Jan 27, 2014
Using AdAway v2.8 but end up getting stuck on the final step to enabling ad blocking, "Applying hosts file".
If you are trying to enable AdAway but are stuck on "Applying hosts file" as seen in the screenshot below:
1. Download a root explorer. I prefer using Root Explorer because I think its the best file explorer on the android market. If you have problems with purchasing apps you can always use the free version Explorer, or if you prefer using another file explorer that's fine, just make sure it has root access enabled.
2. Once you have a file explorer installed that has root access enabled, navigate to "system/etc" and find the file labeled "hosts" as seen in the screenshot below.
3. Hold down/select the file labeled "hosts" and select "permissions" from the selection as seen in the screenshot below.
4. After selecting permissions a window should have popped up where you can change the permissions of the file as seen in the screenshot below.
5. Change the permissions of the hosts file to "rw-rw-rw" just like in the screenshot below. Hit "OK" to apply the permission changes and close the file explorer completely and head back over to AdAway.
6. Once you have AdAway back open, click "Download files and apply ad blocking" and try again. Depending on your internet connection it shouldn't take very long, but you should see something like this, hit "Yes".
7. After your phone has rebooted, open AdAway again and you should see something like this saying newest hosts files enabled.
AdAway is now working and ad blocking is enabled!
View 9 Replies
View Related