当前位置: 首页>>代码示例>>Java>>正文


Java Handler.sendEmptyMessageDelayed方法代码示例

本文整理汇总了Java中android.os.Handler.sendEmptyMessageDelayed方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.sendEmptyMessageDelayed方法的具体用法?Java Handler.sendEmptyMessageDelayed怎么用?Java Handler.sendEmptyMessageDelayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.Handler的用法示例。


在下文中一共展示了Handler.sendEmptyMessageDelayed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showTopButton

import android.os.Handler; //导入方法依赖的package包/类
private void showTopButton() {
    Log.d("delf", "[SYSTEM] show top button");
    Log.d("delf", "[SYSTEM] start topService");

    if(TopService.isRunning) {
        Log.d("delf", "[SYSTEM] TopService is running.");
    } else {
        Log.d("delf", "[SYSTEM] TopService is not running.");
    }
    startService(new Intent(getApplicationContext(), TopService.class));

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            stopService(new Intent(getApplicationContext(), TopService.class));
        }
    };
    handler.sendEmptyMessageDelayed(0, 5000);
    Log.d("delf", "[SYSTEM] showTopButton() is end");
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-AndroidClient,代码行数:22,代码来源:ClipboardService.java

示例2: init

import android.os.Handler; //导入方法依赖的package包/类
public void init(String gpioPin) throws IOException {
    buzzer = new Speaker(gpioPin);
    buzzer.stop(); // in case the PWM pin was enabled already

    handlerThread.start();
    handler = new Handler(handlerThread.getLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            try {
                buzzer.stop();
                if (msg.what == HANDLER_MSG_PLAY) {
                    buzzer.play(msg.arg1);
                    handler.sendEmptyMessageDelayed(HANDLER_MSG_STOP, 800);
                }
            } catch (IOException e) {
                Log.e(TAG, "Buzzer error", e);
            }
        }
    };
}
 
开发者ID:Nilhcem,项目名称:mpr121-androidthings,代码行数:22,代码来源:PassiveBuzzerHelper.java

示例3: initData

import android.os.Handler; //导入方法依赖的package包/类
@Override
protected void initData() {
    mUri = getIntent().getData();
    if (mUri != null) {
        roomId = mUri.getLastPathSegment();
    } else {
        roomId = getIntent().getStringExtra("roomId");
    }

    mTitles = new String[]{"聊天", "主播"};
    mViewList = new ArrayList<>();
    mPagerAdapter = new LiveRoomViewPagerAdapter(mTitles);
    initPagerView();
    mViewPager.setAdapter(mPagerAdapter);
    mTabLayout.setupWithViewPager(mViewPager);

    //初始化handler 刚进来mControlLayout是显示的,发送个延时消息 5秒后自动隐藏
    mControlHandler = new Handler(this);
    mControlHandler.removeMessages(HANDLER_HIDE_CONTROL);
    mControlHandler.sendEmptyMessageDelayed(HANDLER_HIDE_CONTROL, HANDLER_HIDE_TIME);

    mRoomPresenter.attachView(this);
    mRoomPresenter.getRoomInfo(roomId);
    mRoomPresenter.getChatListInfo(roomId);

}
 
开发者ID:yinyiliang,项目名称:RabbitCloud,代码行数:27,代码来源:LiveRoomActivity.java

示例4: onCreate

import android.os.Handler; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_comic_read);
    Intent intent = getIntent();
    comicUrlGet = intent.getStringExtra(ComicFragment.COMICREADURL);
    comicUrl = getComicUrl(comicUrlGet);
    //pictureId = comicUrl.substring(comicUrl.lastIndexOf("/") + 1,comicUrl.lastIndexOf("."));
    //.replace(".html","_2.html");
    //Log.d("url",comicUrl);
    comicSelectPage = (Button) findViewById(R.id.comic_selectPage);
    comicSelectPage.setOnClickListener(this);
    tvComicReadPage = (TextView) findViewById(R.id.comic_readPage);
    tvComicUrlLines = (TextView) findViewById(R.id.comic_change_lines);
    tvComicUrlLines.setOnClickListener(this);
    setTVComicUrlLines(tvComicUrlLines);
    progressBar = (ProgressBar) findViewById(R.id.pb_comic_progress);
    llComicReadBar = (LinearLayout) findViewById(R.id.comic_read_llbar);
    comicPagesText = (TextView) findViewById(R.id.read_comic_pages);
    viewPager = (ViewPager) findViewById(R.id.comic_read_pager);
    //viewPager.setOnLongClickListener(this);
    viewPager.setOffscreenPageLimit(1);
    pageAdapter = new MyPageAdapter(this.getSupportFragmentManager(), comicViewPagerList);
    viewPager.setAdapter(pageAdapter);
    viewPager.setPageTransformer(true, new DepthPageTransformer());
    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 1) {
                llComicReadBar.setVisibility(View.GONE);
            }
        }
    };
    handler.sendEmptyMessageDelayed(1, 3000);
    queryComicUrl();
}
 
开发者ID:NicoLiutong,项目名称:miaosou,代码行数:38,代码来源:ComicReadActivity.java

示例5: WXLocationListener

import android.os.Handler; //导入方法依赖的package包/类
private WXLocationListener(LocationManager locationManager, WXSDKInstance instance, String watchId, String sucCallback, String errorCallback, boolean enableAddress) {
      mWXSDKInstance = instance;
      this.mWatchId = watchId;
      this.mSucCallback = sucCallback;
      this.mErrorCallback = errorCallback;
      this.mEnableAddress = enableAddress;
      mHandler = new Handler(this);
      mLocationManager = locationManager;
//      WVThreadPool.getInstance().execute(new Runnable() {
//        public void run() {
          mHandler.sendEmptyMessageDelayed(TIME_OUT_WHAT, GPS_TIMEOUT);
//        }
//      });
    }
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:15,代码来源:DefaultLocation.java

示例6: onOptionsItemSelected

import android.os.Handler; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    Handler delayedDisconnect = new Handler() {
        public void handleMessage(Message msg) {
            AppState.getInstance().conn.disconnect();
        }
    };

    if(id == R.id.menuBTConnect) {
        bt.setDeviceTarget(BluetoothState.DEVICE_OTHER);
        Intent intent = new Intent(getApplicationContext(), DeviceList.class);
        startActivityForResult(intent, BluetoothState.REQUEST_CONNECT_DEVICE);
    } else if(id == R.id.menuBTDisconnect) {
        if (bt.getServiceState() == BluetoothState.STATE_CONNECTED) {
            AppState.getInstance().onBeforeDisconnect();
            delayedDisconnect.sendEmptyMessageDelayed(0, 100);
        }
    } else if(id == R.id.menuUDPConnect) {
        udp.connect(getGatewayIP(), 0);
        useUDP();
    } else if(id == R.id.menuUDPDisconnect) {
        AppState.getInstance().onBeforeDisconnect();
        delayedDisconnect.sendEmptyMessageDelayed(0, 100);
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:voroshkov,项目名称:Chorus-RF-Laptimer,代码行数:32,代码来源:MainActivity.java

示例7: init

import android.os.Handler; //导入方法依赖的package包/类
private void init(Context context) {
        mPaint = new Paint();
        mPaint.setColor(0xffFF5317);
        mPaint.setStyle(Paint.Style.FILL);
        mPaint.setAntiAlias(true);

        okBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.check);

        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                if (animState == ANIM_CHECK) {
                    animCurrentPage++;
                } else if (animState == ANIM_UNCHECK) {
                    animCurrentPage--;
                }
                if (animCurrentPage < animMaxPage && animCurrentPage >= 0) {
                    invalidate();
//                    animCurrentPage ++;
                    mHandler.sendEmptyMessageDelayed(0, animDuration / animMaxPage);
                } else {

                }
            }
        };
    }
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:28,代码来源:CheckView.java

示例8: initHandler

import android.os.Handler; //导入方法依赖的package包/类
/**
 * 初始化handler,当ViewDragHelper释放了mContentView时,
 * 我们通过循环发送消息刷新mRainbowView的位置和角度
 */
private void initHandler() {
    mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 0:
                    if (rainbowTop > rainbowStartTop) {
                        rainbowTop -= 10;
                        requestLayout();
                        mHandler.sendEmptyMessageDelayed(0, 15);
                    }
                    break;
                case 1:
                    if (rainbowTop <= rainbowStickyTop) {
                        if (rainbowTop < rainbowStickyTop) {
                            rainbowTop += 10;
                            if (rainbowTop > rainbowStickyTop) {
                                rainbowTop = rainbowStickyTop;
                            }
                        }
                        mRainbowView.setRotation(rainbowRotateAngle -= 10);
                    } else {
                        mRainbowView.setRotation(rainbowRotateAngle += 10);
                    }

                    requestLayout();

                    mHandler.sendEmptyMessageDelayed(1, 15);
                    break;
            }
        }
    };
}
 
开发者ID:starryxp,项目名称:LQRWeChat-master,代码行数:39,代码来源:FriendRefreshView.java


注:本文中的android.os.Handler.sendEmptyMessageDelayed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。