當前位置: 首頁>>代碼示例>>Java>>正文


Java Handler.postDelayed方法代碼示例

本文整理匯總了Java中android.os.Handler.postDelayed方法的典型用法代碼示例。如果您正苦於以下問題:Java Handler.postDelayed方法的具體用法?Java Handler.postDelayed怎麽用?Java Handler.postDelayed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Handler的用法示例。


在下文中一共展示了Handler.postDelayed方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.os.Handler; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_splash);


    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
            finish();
        }
    }, 2000L); //3000 L = 3 detik
}
 
開發者ID:mnirfan,項目名稱:FLSGuide,代碼行數:18,代碼來源:Splash.java

示例2: onCreate

import android.os.Handler; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview_chart);
    lv = (ListView) findViewById(R.id.listView1);
    //subscribe();

    // TEST //
    final Handler mHandler = new Handler();
    mHandler.postDelayed(new Runnable() {
        public void run() {
            final ArrayList<ChartItem> items = testCase();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    cda = new ChartDataAdapter(getApplicationContext(), items);
                    lv.setAdapter(null);
                    lv.setAdapter(cda);
                }
            });
            mHandler.postDelayed(this, 8000);
        }
    }, 5000);
}
 
開發者ID:Ksj7,項目名稱:Rabbitqueue,代碼行數:25,代碼來源:MainActivity.java

示例3: queryLatLngAddress

import android.os.Handler; //導入方法依賴的package包/類
private void queryLatLngAddress(LatLng latlng) {
	if(!TextUtils.isEmpty(addressInfo) && latlng.latitude == latitude && latlng.longitude == longitude) {
		return;
	}
	
	Handler handler = getHandler();
	handler.removeCallbacks(runable);
	handler.postDelayed(runable, 20 * 1000);// 20s超時
	geocoder.queryAddressNow(latlng.latitude, latlng.longitude);
	
	latitude = latlng.latitude;
	longitude = latlng.longitude;
	
	this.addressInfo = null;
	setPinInfoPanel(false);
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:17,代碼來源:LocationAmapActivity.java

示例4: animationIn

import android.os.Handler; //導入方法依賴的package包/類
public static void animationIn(final View view, final int animation, int delayTime, final Context context) {
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            Animation inAnimation = AnimationUtils.loadAnimation(
                    context.getApplicationContext(), animation);
            view.setAnimation(inAnimation);
            view.setVisibility(View.VISIBLE);
        }
    }, delayTime);
}
 
開發者ID:vipulyaara,項目名稱:betterHotels,代碼行數:12,代碼來源:Utils.java

示例5: onCreate

import android.os.Handler; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    logoImageView = (ImageView) findViewById(R.id.ivLogo);
    logoImageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.spruce_logo));

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(SplashActivity.this, SpruceActivity.class));
            finish();
        }
    }, SPLASH_TIMEOUT);

}
 
開發者ID:willowtreeapps,項目名稱:spruce-android,代碼行數:19,代碼來源:SplashActivity.java

示例6: animateToActive

import android.os.Handler; //導入方法依賴的package包/類
public void animateToActive() {
    m_isOnScreen = true;

    animateViewToY((int) m_topYPosActive);
    animateViewToX((int) m_leftXPosActiveBackButton, (int) m_leftXPosActiveFloorListContainer, m_isOnScreen);

    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            int[] rootViewPosition = {0, 0};
            m_uiRootView.getLocationInWindow(rootViewPosition);
            int[] backButtonPosition = {0, 0};
            m_backButton.getLocationInWindow(backButtonPosition);
            int[] floorButtonPosition = {0, 0};
            m_floorButton.getLocationInWindow(floorButtonPosition);
        }
    }, m_stateChangeAnimationTimeMilliseconds + (m_isOnScreen ? m_stateChangeAnimationDelayMilliseconds : 0));
}
 
開發者ID:wrld3d,項目名稱:android-api,代碼行數:20,代碼來源:IndoorMapView.java

示例7: onReceive

import android.os.Handler; //導入方法依賴的package包/類
@Override
public void onReceive(final Context context, Intent intent) {
    String action = intent.getAction();

    if (action == null) {
        return;
    }

    if (action.equals("android.intent.action.BOOT_COMPLETED")) {
        final Handler handler = new Handler();
        handler.postDelayed(() -> {
            Intent startIntent = new Intent();
            startIntent.setClassName("guepardoapps.mediamirror", "guepardoapps.mediamirror.activity.FullscreenActivity");
            startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(startIntent);
        }, DELAY);
    }
}
 
開發者ID:GuepardoApps,項目名稱:LucaHome-AndroidApplication,代碼行數:19,代碼來源:BootReceiver.java

示例8: showCancelButtonDelayed

import android.os.Handler; //導入方法依賴的package包/類
public void showCancelButtonDelayed(int delay_ms){
    final Handler handler = new Handler();
    handler.postDelayed(() -> {
        if (viewFlipper.getDisplayedChild() == VIEWFLIPPER_UPDATING) {
            findViewById(R.id.action_cancelUpdate).setVisibility(View.VISIBLE);}
    }, delay_ms);
}
 
開發者ID:PaulKlinger,項目名稱:Sprog-App,代碼行數:8,代碼來源:MainActivity.java

示例9: onCreate

import android.os.Handler; //導入方法依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    initializeIfNeeded();
    HandlerThread thread = new HandlerThread("CloudPublisherService");
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new Handler(mServiceLooper);
    mServiceHandler.postDelayed(mSensorConsumerRunnable, PUBLISH_INTERVAL_MS);
}
 
開發者ID:androidthings,項目名稱:sensorhub-cloud-iot,代碼行數:11,代碼來源:CloudPublisherService.java

示例10: onPrepared

import android.os.Handler; //導入方法依賴的package包/類
/**
 * ピックアップビデオ準備完了
 */
@Override
public void onPrepared(MediaPlayer mp) {
    int height = mp.getVideoHeight();
    int width = mp.getVideoWidth();

    int[] outSize = calcVideoSize(width, height);

    ViewGroup.LayoutParams layoutParams = mPickedVideoView.getLayoutParams();
    layoutParams.width = outSize[0];
    layoutParams.height = outSize[1];

    mRootView.requestLayout();

    mp.start();

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mPickedVideoView.setVisibility(View.VISIBLE);
            mPickedVideoView.startAnimation(
                    AnimationUtils.loadAnimation(
                            getActivity().getApplicationContext(), R.anim.fadein_anim));
        }
    }, 200);
}
 
開發者ID:ficklerobot,項目名稱:grid-video-viewer,代碼行數:30,代碼來源:VideoGridFragment.java

示例11: run

import android.os.Handler; //導入方法依賴的package包/類
@Override
public void run() {
    final Tag tag = getTag();
    if (tag != null) {
        try {
            final Method getTagService = Tag.class.getMethod("getTagService");
            final Object tagService = getTagService.invoke(tag);
            final Method getServiceHandle = Tag.class.getMethod("getServiceHandle");
            final Object serviceHandle = getServiceHandle.invoke(tag);
            final Method connect = tagService.getClass().getMethod("connect", int.class, int.class);
            final Object result = connect.invoke(tagService, serviceHandle, TECHNOLOGY_ISO_DEP);

            final Handler handler = getHandler();
            if (result != null && result.equals(0) && handler != null && sIsRunning && mCurrentRuntime < RUNTIME_MAX) {
                handler.postDelayed(this, INTERVAL);
                mCurrentRuntime += INTERVAL;
                Log.v(TAG, "Told NFC Watchdog to wait");
            }
            else {
                Log.d(TAG, "result: " + result);
            }
        }
        catch (final Exception e) {
            Log.d(TAG, "WatchdogRefresher.run()", e);
        }
    }
}
 
開發者ID:MiFirma,項目名稱:mi-firma-android,代碼行數:28,代碼來源:NFCWatchdogRefresher.java

示例12: writeSettings

import android.os.Handler; //導入方法依賴的package包/類
private void writeSettings() {
    EditText accountEditText = (EditText) fragmentView
            .findViewById(R.id.account_edittext);
    String accountText = accountEditText.getText().toString();
    EditText passwordEditText = (EditText) fragmentView
            .findViewById(R.id.password_edittext);
    String passwordText = passwordEditText.getText().toString();
    if (accountText.length() > 0 && passwordText.length() > 0) {
        Model.getInstance().saveAccountPassword(accountText, passwordText);
        Handler handler = new Handler();
        Runnable accountRunnable = new AccountRunnable(handler, getActivity());
        handler.postDelayed(accountRunnable, 500);
    }
}
 
開發者ID:kamisakihideyoshi,項目名稱:TaipeiTechRefined,代碼行數:15,代碼來源:AccountSettingFragment.java

示例13: getSongs

import android.os.Handler; //導入方法依賴的package包/類
/**
 * Note: {@link LoadSongsCallback#onDataNotAvailable()} is never fired. In a real remote data
 * source implementation, this would be fired if the server can't be contacted or the server
 * returns an error.
 */
@Override
public void getSongs(final @NonNull LoadSongsCallback callback) {
    // Simulate network by delaying the execution.
    Handler handler = new Handler(Looper.getMainLooper());
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            callback.onSongsLoaded(Lists.newArrayList(TASKS_SERVICE_DATA.values()));
        }
    }, SERVICE_LATENCY_IN_MILLIS);
}
 
開發者ID:Captwalloper,項目名稱:NUI_Project,代碼行數:17,代碼來源:SongsRemoteDataSource.java

示例14: DeferredWidgetRefresh

import android.os.Handler; //導入方法依賴的package包/類
DeferredWidgetRefresh(ArrayList<LauncherAppWidgetInfo> infos,
        LauncherAppWidgetHost host) {
    mInfos = infos;
    mHost = host;
    mHandler = new Handler();
    mRefreshPending = true;

    mHost.addProviderChangeListener(this);
    // Force refresh after 10 seconds, if we don't get the provider changed event.
    // This could happen when the provider is no longer available in the app.
    mHandler.postDelayed(this, 10000);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:13,代碼來源:Workspace.java

示例15: onOptionsItemSelected

import android.os.Handler; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            super.onBackPressed();
            return true;
        case R.id.action_settings:
            NavigationUtils.navigateToSettings(this);
            return true;
        case R.id.action_shuffle:
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    MusicPlayer.shuffleAll(BaseActivity.this);
                }
            }, 80);

            return true;
        case R.id.action_search:
            NavigationUtils.navigateToSearch(this);
            return true;
        case R.id.action_equalizer:
            NavigationUtils.navigateToEqualizer(this);
            return true;

    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:30,代碼來源:BaseActivity.java


注:本文中的android.os.Handler.postDelayed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。