Activity runOnUiThread - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Activity runOnUiThread method.

This code example shows how to use the following methods:runOnUiThread
		this.ofActivity = ofActivity;
	} 
	 
	void startGPS(){ 
		final OFAndroidGPS gps = this;
		ofActivity.runOnUiThread(new Runnable(){
			public void run(){ 
				// Acquire a reference to the system Location Manager 
				LocationManager locationManager = (LocationManager) ofActivity.getSystemService(Context.LOCATION_SERVICE);
		 
		 
				// Register the listener with the Location Manager to receive location updates 
				locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, gps);
				 
				// Register the listener with the Location Manager to receive location updates 
				locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gps);
				 
				Location lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
				if(lastLocation!=null)
					onLocationChanged(lastLocation);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread, getString, makeText
     * @param resId The resource identifier of the message string 
     * @param formatArgs The format arguments that will be used for substitution. 
     */ 
    public static void showToast( Activity activity, int resId, Object... formatArgs )
    { 
        showToast( activity, activity.getString( resId, formatArgs ) );
    } 
     
    /** 
     * Pop up a temporary message on the device. 
     * @param activity The activity to display from 
     * @param message The message string to display. 
     */ 
    public static void showToast( Activity activity, String message )
    { 
        if( activity == null )
            return; 
         
        if( sToast != null )
        { 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
 
	private void maScreenSetOrientationHelper(final int androidScreenOrientation)
	{ 
		final Activity activity = mContext;
 
		activity.runOnUiThread(new Runnable()
		{ 
			@Override 
			public void run() 
			{ 
				activity.setRequestedOrientation(androidScreenOrientation);
			} 
		}); 
	} 
 
	protected int getSupportedOrientations() 
	{ 
		if (mSupportedOrientations != 0x000000)
		{ 
			return mSupportedOrientations;
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
package com.weibo.sdk.android.demo; 
 
import android.app.Activity; 
import android.widget.TextView; 
import android.widget.Toast; 
 
public class Util { 
    protected static void showToast(final Activity activity,final String content) {
        activity.runOnUiThread(new Runnable() {
             
            @Override 
            public void run() { 
                Toast toast = Toast.makeText(activity, content, Toast.LENGTH_SHORT);
                toast.show();
                 
            } 
        }); 
        
    } 
    protected static void setTextViewContent(final Activity activity,final TextView textView,final String content) {

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
        return imageView;
    } 
 
	public void runOnUiThread(BitmapDisplayer displayer) {
		Activity a = (Activity) imageView.getContext();
		a.runOnUiThread(displayer);
	} 
 
	public Context getContext() {
		return imageView.getContext();
	} 
 
	public void setBitmap(Bitmap bitmap) {
		imageView.setImageBitmap(bitmap);
 
        stopExistingAnimation(); 
        if (animation != null) {
            imageView.startAnimation(animation);
        } 
	} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
 
    public void setPosition(final int left, final int top,
                            final int width, final int height) {
        Log.d("Showtime", "setPosition(" + left + ", " + top + ", " + width + ", " + height);
 
        mActivity.runOnUiThread(new Runnable() {
                public void run() { 
                    FrameLayout.LayoutParams params;
 
                    params = new FrameLayout.LayoutParams(width, height);
                    params.leftMargin = left;
                    params.topMargin = top;
                    VideoRenderer.this.setLayoutParams(params);
                } 
            }); 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
        return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    } 
 
    public static void pushBitmap(final Bitmap b) {
 
        currentActivity.runOnUiThread(new Runnable() {
                public void run() { 
 
                    SurfaceHolder sh = sv.getHolder();
 
                    sh.setFormat(PixelFormat.RGBA_8888);
 
                    Canvas c = sh.lockCanvas();
                    c.drawBitmap(b, null, sh.getSurfaceFrame(), null);
                    sh.unlockCanvasAndPost(c);
                } 
            }); 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
public class Run { 
 
    private final static Executor backgroundExecutor = Executors.newCachedThreadPool();
 
    public static void onUiThread(Runnable r, Activity a) {
        a.runOnUiThread(r);
    } 
 
    public static void inBackground(Runnable r) {
        backgroundExecutor.execute(r);
    } 
     
    public static void delayed(Runnable r, long delayMillis) {
        Handler h = new Handler();
        h.postDelayed(r, delayMillis);
    } 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
    // Used to indicate that the Browser should continue loading the main page. 
    // This can happen on success, error, or timeout. 
    private synchronized void done() { 
        if (mRunnable != null) {
            Log.d(LOGTAG, "Finished login attempt for " + mAccount.name);
            mActivity.runOnUiThread(mRunnable);
 
            try { 
                mProgressDialog.dismiss();
            } catch (Exception e) {
                // TODO: Switch to a managed dialog solution (DialogFragment?) 
                // Also refactor this class, it doesn't 
                // play nice with the activity lifecycle, leading to issues 
                // with the dialog it manages 
                Log.w(LOGTAG, "Failed to dismiss mProgressDialog: " + e.getMessage());
            } 
            mRunnable = null;
            mActivity.runOnUiThread(new Runnable() {
                @Override 
                public void run() { 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:runOnUiThread
                return; 
            mMemoryCache.put(mImageToLoad.source, bmp);
            if (imageViewReused(mImageToLoad)) return;
            final BitmapDisplayer bd = new BitmapDisplayer(bmp, mImageToLoad);
            final Activity a = (Activity) mImageToLoad.imageview.getContext();
            a.runOnUiThread(bd);
        } 
    } 
 
    private static class ImageToLoad { 
 
        public final URL source;
        public final ImageView imageview;
 
        public ImageToLoad(final URL source, final ImageView imageview) {
            this.source = source;
            this.imageview = imageview;
        } 
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Activity runOnUiThread Questions & Answers:

Other Activity runOnUiThread Examples

183:				List<NameValuePair> params = new ArrayList<NameValuePair>();
184:				params.add(new BasicNameValuePair("name", newCategory));
185:	
186:				ServiceHandler serviceClient = new ServiceHandler();
187:

Read More

137:				
138:				// updating UI from Background Thread
139:				runOnUiThread(new Runnable() {
140:					public void run() {
141:

Read More

191:					e.printStackTrace();
192:				}
193:	
194:				return null;
195:			}

Read More

runOnUiThread Method Overview
Runs the specified action on the UI thread.
See Code Examples for other Android Activity Methods: