Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Thread timeout_request = new Thread(new Runnable() {
- public void run() {
- try{
- Log.d(TAG, "Thread start");
- Thread.sleep(30000);
- Log.d(TAG, "Thread awake");
- if(!httprequest_finished){
- request_aborted = true;
- mHttpClient.getConnectionManager().shutdown();
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- });
- public String sendData(String token){
- ...
- timeout_request.start();
- Log.i(TAG, "Sending request");
- final HttpResponse resp = httpClient.execute(post);
- Log.i(TAG, "Execute finished");
- if(request_aborted) return null;
- httprequest_finished = true;
- ...
- }
- private Handler mHandler = new Handler();
- private Runnable r = new Runnable() {
- public void run() {
- Log.d(TAG, "Runnable()");
- if(!httprequest_finished){
- request_aborted = true;
- mHttpClient.getConnectionManager().shutdown();
- }
- }
- };
- threadid=3: reacting to signal 3
- Wrote stack traces to '/data/anr/traces.txt'
- threadid=3: reacting to signal 3
- Wrote stack traces to '/data/anr/traces.txt'
- Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
- public void uncaughtException(Thread paramThread, Throwable paramThrowable) {
- Log.e("Alert","Lets See if it Works !!!");
- }
- });
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- /**
- *
- * @author paro
- */
- public class JavaApplication1 {
- public boolean req_aborted = false;
- public Thread timeout_request = new Thread(new Runnable() {
- public void run() {
- try{
- System.out.println("start");
- Thread.sleep(30000);
- System.out.println("awake");
- if(req_aborted ==false)
- {
- req_aborted = true;
- System.out.println("flag change");
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }
- });
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- JavaApplication1 jap = new JavaApplication1();
- jap.timeout_request.start();
- System.out.println("requset started");
- if(jap.req_aborted)
- {
- System.out.println("flag is true now");
- }
- }
- }
- requset started
- start
- awake
- flag change
- final HttpResponse resp = httpClient.execute(post);
- Handler mHandler = new Handler();
- ...
- mhandler.postDelayed(new Runnable() {
- public void run() {
- if(!httprequest_finished){
- request_aborted = true;
- mHttpClient.getConnectionManager().shutdown();
- }
- }
- }, 30000);
- response.getStatusLine().getStatusCode()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement