List of usage examples for android.os Handler post
public final boolean post(Runnable r)
From source file:Main.java
public static void setClipBoard(final Context context, final String msg, Handler handler) { Runnable updater = new Runnable() { public void run() { ClipboardManager clip = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText("Remoteroid_Clip", msg); clip.setPrimaryClip(data);//w ww .ja v a 2 s . co m } }; handler.post(updater); }
From source file:edu.cmu.android.restaurant.authentication.NetworkUtilities.java
/** * Sends the authentication response from server back to the caller main UI * thread through its handler./*from w ww . ja va2 s . c o m*/ * * @param result * The boolean holding authentication result * @param handler * The main UI thread's handler instance. * @param context * The caller Activity's context. */ private static void sendResult(final Boolean result, final Handler handler, final Context context) { if (handler == null || context == null) { return; } handler.post(new Runnable() { public void run() { ((LoginActivity) context).onAuthenticationResult(result); } }); }
From source file:org.thaliproject.nativetest.app.MainActivity.java
/** * Displays a toast with the given message. * @param message The message to show.//from w w w.ja v a 2s .c o m */ public static void showToast(final String message) { final Context context = mContext; if (context != null) { Handler handler = new Handler(mContext.getMainLooper()); handler.post(new Runnable() { @Override public void run() { CharSequence text = message; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } }); } }
From source file:com.bearstech.android.myownsync.client.NetworkUtilities.java
/** * Sends the authentication response from server back to the caller main UI * thread through its handler.// www . ja v a 2 s . c om * * @param result The boolean holding authentication result * @param handler The main UI thread's handler instance. * @param context The caller Activity's context. */ private static void sendResult(final Boolean result, final Handler handler, final Context context) { if (handler == null || context == null) { return; } handler.post(new Runnable() { public void run() { ((AuthenticatorActivity) context).onAuthenticationResult(result); } }); }
From source file:com.arellomobile.android.push.PushManager.java
public static void sendTags(final Context context, final Map<String, Object> tags, final SendPushTagsCallBack callBack) { Handler handler = new Handler(context.getMainLooper()); handler.post(new Runnable() { @SuppressWarnings("unchecked") public void run() { new SendPushTagsAsyncTask(context, callBack).execute(tags); }/*ww w .j av a 2 s . c o m*/ }); }
From source file:com.google.android.gcm.demo.ui.MainActivity.java
static public void showToast(final Context context, final int msgId, final Object... args) { Handler handler = new Handler(context.getMainLooper()); handler.post(new Runnable() { public void run() { Toast.makeText(context, context.getString(msgId, args), Toast.LENGTH_LONG).show(); }/* w w w.j ava 2 s . c om*/ }); }
From source file:com.trk.aboutme.facebook.Settings.java
/** * Manually publish install attribution to the Facebook graph. Internally handles tracking repeat calls to prevent * multiple installs being published to the graph. * @param context the current Context/*from www . j a v a 2s . c om*/ * @param applicationId the fb application being published. * @param callback a callback to invoke with a Response object, carrying the server response, or an error. */ public static void publishInstallAsync(final Context context, final String applicationId, final Request.Callback callback) { // grab the application context ahead of time, since we will return to the caller immediately. final Context applicationContext = context.getApplicationContext(); Settings.getExecutor().execute(new Runnable() { @Override public void run() { final Response response = Settings.publishInstallAndWaitForResponse(applicationContext, applicationId); if (callback != null) { // invoke the callback on the main thread. Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { callback.onCompleted(response); } }); } } }); }
From source file:com.taxicop.client.NetworkUtilities.java
private static void sendResult(final Boolean result, final Handler handler, final Context context) { if (handler == null || context == null) { return;//from w w w. jav a2 s . c o m } handler.post(new Runnable() { public void run() { ((AuthActivity) context).onAuthenticationResult(result); } }); }
From source file:Main.java
public static Handler runInUIThread(final Runnable runnable, boolean runImmediatelyIfPossible) { if (runnable == null) { return null; }//from w w w .j av a 2 s .c o m final Handler handler; Looper mainLooper = Looper.getMainLooper(); if (runImmediatelyIfPossible && (Thread.currentThread() == mainLooper.getThread())) { handler = null; runnable.run(); } else { handler = new Handler(mainLooper); handler.post(runnable); } return handler; }
From source file:com.nbos.phonebook.sync.client.Net.java
private static void sendNewValidationCodeResult(final Boolean result, final String message, final Handler handler, final Context context) { Log.i(tag, "sendValidationResult(" + result + ")"); if (handler == null || context == null) { return;/* w w w. j a v a 2 s.c om*/ } handler.post(new Runnable() { public void run() { ((ValidationActivity) context).onNewValidationCodeResult(result, message); } }); }