Android :: Http Post Abort Not Returning Immediately When Called From Separate Thread

Mar 24, 2010

I am using a DefaultHttpClient and a ThreadSafeClientConnManager to share the httpClient across threads. That part is working well. However, when I execute an HttpPost in one thread, and call httpPost.abort() from another. It does not return immediately and continues blocking until the socket timeout is reached in most cases. Am I missing something else? I've tried using: connectionManager.closeIdleConnections(30, TimeUnit.SECONDS); connectionManager.closeExpiredConnections();

Android :: Http Post abort not returning immediately when called from separate thread


Android :: How To Use Separate Thread To Perform Http Requests?

Aug 2, 2010

I have an application that is performing HTTP Requests (specifically calling the FogBugz API) when the user clicks certain buttons. Right now, I am just creating a service when the application starts, and then calling different methods in that service to complete requests. However, when I do this, there is the usual hang in the UI thread. I have looked at AsyncTask, but am not sure it will do what I want to accomplish. Because I need to instantly parse the XML that the HTTP Request returns, I need to have a process that is able to return this data to the UI thread. Will ASyncTask be able to accomplish this, or is there some other way.

View 1 Replies View Related

Android :: Use Thread With SurfaceView - Ie Draw In Separate Thread?

Jul 22, 2009

I want to do the drawing in another thread to speed up the game(it is way to slow right now). I was told to do this but don't quite understand why that would speed things up. Is it GameView that should implement Runnable? Should I make the thread sleep when not drawing? where should I start the thread? package com.android.WWS;

import android.app.Activity; import android.content.Context; import android.graphics.*; import android.os.Bundle; import android.view.SurfaceView; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; import java.lang.Runnable; import java.lang.Thread;...................

View 4 Replies View Related

Android :: Returning From HTTP Intent.ACTION_VIEW

Mar 23, 2009

I have an application that needs to have a user visit a web page to authorize it. After spending time in the Browser the user should return the my application.

Currently, I'm launching the Browser with:

CODE:................

After using the browser, I can go back home and launch my application, which stacks a new Activity on top of the previous stack of Activities that were being used in the application. For example. If the user launches the app, they have Activity A in the stack. From there we navigate to Activity B which then launches the Browser. Then, the next time we enter the app, we launch Activity A, which is pushed onto the stack that already contains an A and B.

My question is then, how can I just go back to the previous stack? Basically, do I have to create a new Activity? Is there a better way to launch the Browser, and then come back to my application?

Also, I've been using the Intent.FLAG_ACTIVITY_NEW_TASK when I start the Browser activity so that my app stays running.

View 2 Replies View Related

Android :: Remote Service Returning Value From Http Transaction

May 6, 2009

I've been researching how to best implement a service which performs a network transaction and returns data to the caller.

Clearly, this needs to happen on its own thread which means some form of async response. I can see at least three ways of doing this--some more complex than others. In the descriptions below, C is the caller, S is the service.

1) C wraps a Handler in a Messenger object, adds this to an Intent. C then calls startService with this intent. S extends IntentService which runs the Intents received in a worker thread. S then sends a message to C via the Messenger. This has the benefit of not requiring any of the async binding process or making an IDL interface that needs to be compiled into C. This seems to be the closes to a Handler-based response mechanism of Local Services.

2) C binds to S and then uses AsyncTask<> to make a blocking call to S. S performs the network transaction and returns the data in the return value or an out parameter. This requires the async binding process, but does not require a callback function since the inter- thread communications is handled by AsyncTask<> and the worker thread is in C's context.

3) Make the function called in S be completely asynchronous. S defines two interfaces: IMyService and IMyServiceCallback. S implements IMyService.Stub. C implements IMyServiceCallback.Stub. C binds to S then calls S via IMyService, passing its IMyServiceCallback binder. S spins up a worker thread and returns immediately. S then calls the callback when it has completed the network transaction.

I am asking for advice on which methods are most appropriate. I do not need the the service running constantly, only when the web transaction is required. C does not use S all the time--definitely don't want to bind during C's onCreate. However, I would like the time from when C determines it needs to use S to getting the results back to be as quick as possible (i.e. adding minimal latency to the already latent network access).

Is there any preference to having the worker thread in C or in S? Are there any significant problems with option 1?

View 11 Replies View Related

Android :: Doing HTTP Post?

Oct 12, 2010

I need to pass some values to a URL by Post Method in my apllication. Please Help

View 2 Replies View Related

Android :: What Version Of Apache HTTP Client Is Bundled / Need Separate Project To Run

Apr 11, 2010

I want to have a separate project that runs my server communication code in a normal JVM for the purposes of integration testing. This code uses these libraries which are build into the Android Framework...

http://developer.android.com/reference/org/apache/http/client/package-summary.html

Does anybody know what version of Apache HTTP Client this is supposed to be? I want to run it without the Android tests which are painfully slow.

View 2 Replies View Related

Android :: Secure HTTP Post?

Feb 12, 2010

I have a pretty basic helper class that I'm using to do all my Http Get/Post stuff. I'm using HttpGet, HttpPost, and HttpClient from the org.apache.http library. All of my stuff works fine over HTTP, but as soon as I tried to consume a service that works over HTTPS, I get a ClientProtocolException when executing the request. The only message in the exception is "The server failed to respond with a valid HTTP response".

To test, I sent the exact same payload from a browser using a simple html form and Fiddler2 using the RequestBuilder. I've sent invalid and empty payloads and even sent all of the above with and without headers to see if there was something funky about the way the objects were building the request.

Everything I've used in testing gives me a valid 200 status HTTP response. The service just gives me a structure describing the error if I give it something other than what it expects.

Is there something special I need to add to the HttpPost or HttpClient object(s) to tell it to use HTTPS? Do I have to explicitly tell it to use a different port?

I indeed registered the wrong socket factory for https communication. Here is the updated method that I use to create my HttpClient object with the correct socket factory just in case someone searches this kind of problem in the future:

CODE:............................

View 3 Replies View Related

Android :: Can Not Send Http Post?

Jun 13, 2010

I've been banging my head trying to figure out how to send a post method in Android.

This is how my code look like:

CODE:..................

This is the exception that I get:

CODE:............

Is there anything that I may need to configure from the Android emulator to get this working?

View 2 Replies View Related

Android :: Http Post With Parameter?

Jul 6, 2010

I want to send data to server from client(Android)

Below is my format.

CODE:......................

I'm trying series of trial but no use, how this can be done?

View 1 Replies View Related

Android :: Add Parameters In Http Post?

Jul 20, 2010

I am trying to upload file to php server using following tutorial http://getablogger.blogspot.com/2008/01/android-how-to-post-file-to-php-server.html

I dont know how to add parameters like: userid="12312";sessionid="234" in it.

How to achieve this?

View 1 Replies View Related

Android :: Making An HTTP POST?

Sep 6, 2010

I'm getting a problem making an HTTP POST in Android.

The problem occur when the code is reading the response, it cant obtain the complete web page code I want to retrieve.

I only retrieve a piece of the web.

Here is the code:

CODE:..............

View 2 Replies View Related

Android :: Can't Do A HTTP Post To A Web Service From My App

Sep 8, 2010

I've been working on an app that uses both GET and POST requests to Web Services. The GET requests are no problems but the POST requests are killing me. I've tried 2 different scenarios in the code. The first looks like this...

CODE:......

This code gets this result for me..."Bad Request (Invalid Header Name)"

Now here's my second piece of code...

CODE:.....

This gives me an entirely different result. It's a long garbled mess of xml and SOAP that does have a SOAP Exception mentioned in it..."Server was unable to process request. --- System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1." Now, can anyone shed any light on what I am doing wrong.

View 1 Replies View Related

Android :: Protect HTTP Request From Being Called By Others

Jun 18, 2010

I have an Android application from which I want to upload some data to a database on my web server. As the MySql java library has a size of about 5 mb, I don't want to include it with the application.So I'll make a HTTP request for a php script and send the data with the URL as parameters. How do I make sure that only I can call this? I don't want people to sniff up the URL and call it outside my application.

View 3 Replies View Related

Android :: Uploading File Through HTTP Post

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

Android :: Starting Service In Separate Thread

Jul 27, 2009

i have a little frontend showing a list of items that it will retrieve from a service. I want that service to be started in a separate thread.so the UI is still responding to user interaction while waiting for that service to call a callback method. What is the best way to start the service in a detached thread?

View 6 Replies View Related

Android :: HTTP Multipart POST - Data - Text

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

Android :: Test Http Post Response In Emulator?

Oct 26, 2010

Let's say I want to perform a quick HTTP post to a website within my android app. If I were to set up the http client and send the post all in the onCreate method of the main screen (inside the UI thread) just for testing purposes, what would I use to quickly see what the response is to the post? I tried something quick and dirty below inside the onCreate method when the app first opens and nothing really happens, is there something more I need to do/obviously my toast idea is just bad.

HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://forecast.weather.gov/zipcity.php?inputstring=04419");
HttpResponse httpResp;
try {
httpResp = httpClient.execute(post);
StatusLine status = httpResp.getStatusLine();
Toast.makeText(getApplicationContext(), (CharSequence) status, Toast.LENGTH_SHORT).show();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();}

View 1 Replies View Related

Android :: HTTP Post Issue - Get The Status Code As 405

May 2, 2010

CODE:..............

Always, I get the status code as 405. I tried request queue as well.. sneding the byte array as part of the request queue, still the same issue.

View 1 Replies View Related

Android :: HTTP Post Works In Activity But Not In Service

Nov 5, 2010

GI am trying to do a http post to a php script. the method works if I place it in the onCreate event of the application but gets a ConnectionTimeOut error when it tries to execute it from the service.

Here is an example of my method

CODE:...................

I have no idea why the service would get a time out error but the application activity would not.

View 5 Replies View Related

Android :: Register Receiver For Events In Separate Thread

Aug 14, 2009

I want a separate thread from a service to register a receiver for wifi events. However as I need a context for doing that (and I'm using service one) I'm receiving the intents on the main thread. Is there any possibility to register a receiver for executing in other thread than main?

View 2 Replies View Related

Android :: Separate Thread Within Application For Bluetooth Connection?

Aug 4, 2010

I want to write a separate Thread within my application (to do Bluetooth connection). Any idea where I can find any reference for help to write Threads in Android? I searched online but could not find any proper reference.

View 5 Replies View Related

How To Change UI From A Separate Thread

Aug 27, 2013

Doing some simple android networking. My problem is as stated above, i would like to change the UI from a separate thread.

What i would like to do is add "Client successfully connected" to the EditText i have. The connection to the server is handled by a separate thread, and that is why i would like to do this. Another reason is, i have a different thread always listening for to what the server says, and what ever the server does say i would like to show it in the EditText.

I always get the following error:

Only the original thread that created a view hierarchy can touch its views

Ran into another problem. My code involves socket connections. It works just fine on the emulator. How ever it doesn't work on my phone. It was working a day or two ago, then just magically stopped. LogCat simply says permission denied.

View 6 Replies View Related

Android :: HTTP Post Does Not Send File MIME Type

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

Android :: Can't Grab Progress On Http POST File Upload / Way To Fix?

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

Android : Need Http Client POST - Null Pointer Exception

Aug 22, 2010

I am new to Android development since my EVO purchase a few months ago. Anyway, I am developing my first Android app using Eclipse and Android SDK emulator. I am trying to do a simple HTTP POST. My real code has my login information hard coded in so I replaced it with test information and I changed the url as well to simply POST to google.com. I am getting a NullPointerException when trying to view the HTTP POST request response. I have added the internet permissions to my manifest xml file as well. Code...

View 1 Replies View Related

Adding JSON To HTTP Post

Aug 11, 2013

I'm trying to access a web service by "Post"-ing a valid email and password.It works in Google chrome, but I have not gotten it to work in Android.Below is my attempt to access the web service but I get a

{"status":"500","error":"Internal Server Error"}
error.
class PostToUnilabLogin extends AsyncTask<String, Integer, String>{
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
[code]...

View 4 Replies View Related

Android :: Use HTTP Post Method Or Simple Java Socket Program

Mar 20, 2010

Could someone please suggest me a good/efficient way to communicate with the server. I could think of two options 1) Use http post methods to send data to a php script at the server which would later call the google api's written in another java program (jar)or use php to use google api's (if its possible) to find nearby restaurants and send the list back to client. 2) Use simple java socket programming. The server has a jar file that supports multi threading and it does the job of finding restaurants and sending the list.

View 4 Replies View Related

Android :: Project Using Httpclient - Http.client - Apache - Post/get Method

May 17, 2009

I'm doing a Get and Post method for an android project and I need to "translate" HttpClient 3.x to HttpClient 4.x (using by android).

My problem is that I'm not sure of what I have done and I don't find the "translation" of some methods...

This is the HttpClient 3.x I have done and (-->) the HttpClient 4.x "translation" if I have found it (Only parties who ask me problems) :

CODE:...........

I don't know if that is correct. This has caused problems because the packages are not named similarly, and some methods too. I just need documentation (I haven't found) and little help.

View 4 Replies View Related

How To Show Progress Bar On HTTP POST Using Asynctask

Oct 4, 2011

I am trying to upload a video to an api and I was wondering how you show a progress bar show and also dismiss it when an upload has finished? Also, while were at it, do you see anything wrong with my pattern.compile for my edit boxes?

Code:
public class Loadvid extends AsyncTask <Object,Integer,String>{
EditText etxt_user = (EditText) findViewById(R.id.user_email);
EditText etxt_pass = (EditText) findViewById(R.id.friend_email);
[code]...

But it doesn't work. When i click on the button to send, it shows the handler for 2 seconds then brings up an error close.Error log.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved