本文整理汇总了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
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}