Example usage for android.os Handler Handler

List of usage examples for android.os Handler Handler

Introduction

In this page you can find the example usage for android.os Handler Handler.

Prototype

public Handler() 

Source Link

Document

Default constructor associates this handler with the Looper for the current thread.

Usage

From source file:com.arellomobile.android.push.PushGCMIntentService.java

public PushGCMIntentService() {
    String senderId = PushManager.mSenderId;
    Boolean simpleNotification = PushManager.sSimpleNotification;
    if (null != simpleNotification) {
        mSimpleNotification = simpleNotification;
    }//from   ww  w . j  a  v a 2s .  c om
    if (null == senderId) {
        senderId = "";
    }
    mSenderId = senderId;
    mHandler = new Handler();
}

From source file:com.frand.easyandroid.http.FFHttpRespHandler.java

/**
 * FFBaseRespHandler?????/*from w ww . jav a  2  s.co m*/
 */
@SuppressLint("HandlerLeak")
public FFHttpRespHandler() {
    if (Looper.myLooper() != null) {
        handler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                FFHttpRespHandler.this.handleMessage(msg);
            }
        };
    }
}

From source file:com.facebook.android.FriendsList.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();
    setContentView(R.layout.friends_list);

    Bundle extras = getIntent().getExtras();
    String apiResponse = extras.getString("API_RESPONSE");
    graph_or_fql = extras.getString("METHOD");
    try {//from  w  w  w.j  a  v  a2 s  . c  o  m
        if (graph_or_fql.equals("graph")) {
            jsonArray = new JSONObject(apiResponse).getJSONArray("data");
        } else {
            jsonArray = new JSONArray(apiResponse);
        }
    } catch (JSONException e) {
        showToast("Error: " + e.getMessage());
        return;
    }
    friendsList = (ListView) findViewById(R.id.friends_list);
    friendsList.setOnItemClickListener(this);
    friendsList.setAdapter(new FriendListAdapter(this));

    showToast(getString(R.string.can_post_on_wall));
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate() Activity");

    handleExtra(getIntent());/*w  w w. j  a  va 2s.  co  m*/

    keyCheck = new Handler();
    request = new Handler();
    guestServiceCheck = new Handler();

    setContentView(R.layout.activity_lock);
    lock_fragment = (LockActivityFragment) getFragmentManager().findFragmentById(R.id.fragmentlock);
    startRepeatingTask();
}

From source file:com.nokia.example.capturetheflag.network.SocketIONetworkClient.java

public SocketIONetworkClient() {
    mHandler = new Handler();
    mTimer = new Timer();
}

From source file:eu.andlabs.gcp.GCPService.java

@Override
public void onCreate() {
    super.onCreate();
    mName = "AndroidoKa";
    mHandler = new Handler();

    log("starting GCP Service");
    try {//w w  w  . j a v  a 2s .co m
        mSocketIO = new SocketIO("http://may.base45.de:7777", new IOCallback() {

            @Override
            public void onConnect() { // auto login
                log("connected to GCP game server!");
                mSocketIO.emit("login", "I am " + mName);
            }

            @Override
            public void onMessage(String text, IOAcknowledge ack) {
                dispatchMessage(CHAT, text);
            }

            @Override
            public void on(String type, IOAcknowledge ack, Object... data) {
                //                    log("incoming message:" + type + " --- " + data);
                if (type.equals("login")) {
                    dispatchMessage(LOGIN, data[0].toString());
                } else if (type.equals("players")) {
                    dispatchMessage(LOGIN, data[0].toString());
                } else {
                    dispatchMessage(CHAT, "BAD protocol message: " + type);
                    Log.d("GCP", "" + data[0].getClass().getName());
                }
            }

            @Override
            public void onMessage(JSONObject json, IOAcknowledge ack) {
            }

            @Override
            public void onDisconnect() {
                log("lost game server.");
            }

            @Override
            public void onError(SocketIOException error) {
                log(error);
            }
        });
    } catch (Exception e) {
        log(e);
        dispatchMessage(CHAT, "GCP Service Error:   " + e.toString());
    }
}

From source file:com.facebook.android.UpdateStatusResultDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.update_post_response);
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mOutput = (TextView) findViewById(R.id.apiOutput);
    mOutput.setText(values.toString());//from   w  ww . j  ava  2 s. c om

    mUsefulTip = (TextView) findViewById(R.id.usefulTip);
    mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance());
    mViewPostButton = (Button) findViewById(R.id.view_post_button);
    mDeletePostButton = (Button) findViewById(R.id.delete_post_button);
    final String postId = values.getString("post_id");

    mViewPostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: view_post_tag
             */
            Utility.mAsyncRunner.request(postId, new WallPostRequestListener());
        }
    });
    mDeletePostButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * Source tag: delete_post_tag
             */
            Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE", new WallPostDeleteListener(), null);
        }
    });
}

From source file:com.polyvi.xface.http.XAsyncHttpResponseHandler.java

public XAsyncHttpResponseHandler() {
    if (Looper.myLooper() != null) {
        mHandler = new Handler() {
            @Override/*w w w  .ja v  a 2 s  .c o  m*/
            public void handleMessage(Message msg) {
                XAsyncHttpResponseHandler.this.handleMessage(msg);
            }
        };
    }
}

From source file:com.facebook.android.FQLQuery.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mHandler = new Handler();

    setContentView(R.layout.fql_query);/*ww w. j  ava  2  s  . c  om*/
    LayoutParams params = getWindow().getAttributes();
    params.width = LayoutParams.FILL_PARENT;
    params.height = LayoutParams.FILL_PARENT;
    getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);

    mFQLQuery = (EditText) findViewById(R.id.fqlquery);
    mFQLOutput = (TextView) findViewById(R.id.fqlOutput);
    mSubmitButton = (Button) findViewById(R.id.submit_button);

    mSubmitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                    .hideSoftInputFromWindow(mFQLQuery.getWindowToken(), 0);
            dialog = ProgressDialog.show(FQLQuery.this.activity, "",
                    FQLQuery.this.activity.getString(R.string.please_wait), true, true);
            /*
             * Source tag: fql_query_tag
             */
            String query = mFQLQuery.getText().toString();
            Bundle params = new Bundle();
            params.putString("method", "fql.query");
            params.putString("query", query);
            Utility.mAsyncRunner.request(null, params, new FQLRequestListener());
        }
    });
}

From source file:com.dedipower.portal.android.CreateTicket.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.createticket);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from  w w  w.ja  v  a 2 s .  c  o  m*/
            if (TicketID == 0) {
                Toast.makeText(CreateTicket.this,
                        "Ticket Creation Failed. Please try again later or email request@dedipower.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitTicket = new Thread() {
        public void run() {
            try {
                TicketID = API.CreateTicket(Subject, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button CreateTicketButton = (Button) findViewById(R.id.CreateTicketButton);
    CreateTicketButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText SubjectET = (EditText) findViewById(R.id.Subject);
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Subject = SubjectET.getText().toString();
            Message = MessageET.getText().toString();

            submitTicket.start();
            /*EditText Subject = (EditText) findViewById(R.id.Subject);
            EditText Message = (EditText) findViewById(R.id.Message);
                    
            try 
            {
            TicketID = API.CreateTicket(Subject.getText().toString() , Message.getText().toString());
            } 
            catch (JSONException e) 
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@dedipower.com", Toast.LENGTH_LONG).show();
            }
                    
                    
            if(TicketID == 0)
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@dedipower.com", Toast.LENGTH_LONG).show();
            }
            else
            {
               Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...", Toast.LENGTH_SHORT).show();
               finish();
            }*/
        }
    });
}