当前位置: 首页>>代码示例>>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;未经允许,请勿转载。