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

@UnsupportedAppUsage
public Handler(boolean async) 

Source Link

Document

Use the Looper for the current thread and set whether the handler should be asynchronous.

Usage

From source file:cn.net_show.doctor.activity.AuthActivity.java

@Override
protected void onCreate(Bundle arg0) {
    // TODO Auto-generated method stub
    app = (MyApplication) getApplication();
    httpUtil = HttpUtil.getInstance();//from w  w  w .j  ava2s .  c  om
    jUtils = JsonUtils.getInstance();
    mHandler = new Handler(getMainLooper()) {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 1:
                if (pd != null & pd.isShowing()) {
                    pd.dismiss();
                }
                Toast.makeText(AuthActivity.this, msg.obj.toString(), Toast.LENGTH_SHORT).show();
                break;
            case 2:

                break;
            default:

                break;
            }
        }

    };
    setContentView(R.layout.activity_auth);
    rdgroup = (RadioGroup) findViewById(R.id.radiogroup);
    authImage = (ImageButton) findViewById(R.id.authImage);
    rdgroup.setOnCheckedChangeListener(this);
    type = (TextView) findViewById(R.id.tv_type);
    super.onCreate(arg0);
}

From source file:com.example.gcmandroid.GcmService.java

private void sendNotification(final String msg) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override//from   www  .ja  v  a2  s  .c  o  m
        public void run() {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
            if (MainActivity.mTextView != null) {
                MainActivity.mTextView.setText(msg);
            }
        }
    });
}

From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationProvider.java

public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
    Looper looper = handlerThread.getLooper();
    Handler handler = new Handler(looper);

    return context.registerReceiver(receiver, filter, null, handler);
}

From source file:com.hybris.mobile.activity.CheckoutActivity.java

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

    getActionBar().setHomeButtonEnabled(true);
    setContentView(R.layout.checkout_list);
    setTitle(R.string.checkout_page_title);

    controller = new CartController(new Cart(), this);
    controller.addOutboxHandler(new Handler(this));

    colorStepDone = getResources().getColor(R.color.textHighlightedDark);
    colorStepCurrent = getResources().getColor(R.color.textHighlighted);
}

From source file:org.projectbuendia.client.diagnostics.UpdateServerHealthCheck.java

@Override
protected void startImpl() {
    synchronized (mLock) {
        if (mHandlerThread == null) {
            mHandlerThread = new HandlerThread("Buendia Update Server Health Check");
            mHandlerThread.start();/*from w  w  w .java 2s  .  com*/
            mHandler = new Handler(mHandlerThread.getLooper());
            mHandler.post(mHealthCheckRunnable);
        }
    }
}

From source file:com.gotraveling.insthub.BeeFramework.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    mHandler = new Handler(this);
    ActivityManagerModel.addLiveActivity(this);
}

From source file:com.BeeFramework.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    mHandler = new Handler(this);
    ActivityManagerModel.addLiveActivity(this);
}

From source file:com.application.utils.ApplicationLoader.java

@Override
public void onCreate() {
    super.onCreate();
    applicationContext = getApplicationContext();
    applicationHandler = new Handler(applicationContext.getMainLooper());
    applicationLoader = this;
    preferences = new AppPreferences(this);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    ExceptionHandler.register(applicationLoader);
}

From source file:com.deltadna.android.sdk.net.NetworkManager.java

public NetworkManager(String envKey, String collectUrl, String engageUrl, Settings settings,
        @Nullable String hash) {/*from ww w .j a v a2s .co m*/

    this.collectUrl = collectUrl + '/' + envKey;
    this.engageUrl = engageUrl + '/' + envKey;
    this.settings = settings;

    this.hash = hash;
    MessageDigest md = null;
    if (hash != null && !hash.isEmpty()) {
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            Log.w(TAG, "Events will not be hashed", e);
        }
    }
    md5 = md;

    dispatcher = new NetworkDispatcher(new Handler(Looper.getMainLooper()));
}

From source file:com.spoiledmilk.ibikecph.map.SMHttpRequest.java

public SMHttpRequest() {

    handler = new Handler(new Handler.Callback() {
        @Override/*from ww w  . j  a v a 2s  . c  o m*/
        public boolean handleMessage(Message msg) {
            Result res = (Result) msg.obj;
            if (res == null)
                return false;

            switch (msg.what) {
            case REQUEST_GET_ROUTE:
                break;
            case REQUEST_FIND_NEAREST_LOC:
                break;
            case REQUEST_FIND_PLACES_FOR_LOC:
                break;
            case REQUEST_GET_RECALCULATED_ROUTE:
                break;
            }

            if (res.listener != null)
                res.listener.onResponseReceived(msg.what, res.response);

            return true;
        }
    });
}