Java Code Examples for android.os.Handler.sendEmptyMessage()

The following are Jave code examples for showing how to use sendEmptyMessage() of the android.os.Handler class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: BluetoothAPP   File: BluetoothUtil.java   View Source Code Vote up 7 votes
/**
     * 连接蓝牙(2)
     *
     * @return
     */
    public static BluetoothSocket connectDevice(final Handler handler) {
        BluetoothSocket socket = null;
        try {
            Comment.SPP_UUID = UUID.fromString("00001106-0000-1000-8000-00805F9B34FB");
            socket = Comment.bluetoothDevice.createRfcommSocketToServiceRecord(Comment.SPP_UUID);
            socket.connect();
            handler.sendEmptyMessage(Comment.CONNECT);
        } catch (Exception e) {
            handler.sendEmptyMessage(2);
            try {
                if (socket!=null)
                socket.close();
            } catch (Exception closeException) {

            }
        }
        return socket;
}
 
Example 2
Project: GitHub   File: QueuesHandler.java   View Source Code Vote up 5 votes
private void freezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_FREEZE);
}
 
Example 3
Project: stynico   File: UiUpdater.java   View Source Code Vote up 5 votes
public static void updateClients() {
	//myLog.l(Log.DEBUG, "UI update");
	//Log.d("UiUpdate", "Update now");
	for (Handler client : clients) {
		client.sendEmptyMessage(0);
	}
}
 
Example 4
Project: Hotspot-master-devp   File: MediaUtils.java   View Source Code Vote up 5 votes
public static void getFolderAllImg(Context context, List<PictureInfo> datas, List<String> childList,final Handler handler) {
        for (int i = 0; i < childList.size(); i++) {
            int startTitle = childList.get(i).lastIndexOf("/") + 1;
            int endTitle = childList.get(i).lastIndexOf(".");
            String title = (String) childList.get(i).subSequence(startTitle, endTitle);
            String filename = childList.get(i);

            PictureInfo model = new PictureInfo();
            model.setFunction(ConstantsWhat.FunctionsIds.PREPARE);
            model.setAction("2screen");
            model.setAssettype("pic");
            model.setAssetname(title);
            model.setAssetpath(filename);
//            if (contains(context, title)) {
//                if (application == null) {
//                    application = (SavorApplication) context.getApplicationContext();
//                }
//                model.setAsseturl(application.GalleyPath + title + ".jpg");
//            } else {
            model.setAsseturl(NetWorkUtil.getLocalUrl(context) + filename);
//            }
            datas.add(model);
        }

        handler.sendEmptyMessage(INIT_SUCCESS);
        // calback.setData();
    }
 
Example 5
Project: CoolClock   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    tv_time = (TextView) findViewById(R.id.tv_time);
    tv_date = (TextView) findViewById(R.id.tv_date);
    tv_day = (TextView) findViewById(R.id.tv_day);
    Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/ds_digi.ttf");
    tv_time.setTypeface(typeFace);
    tv_date.setTypeface(typeFace);
    tv_weather = (TextView) findViewById(R.id.tv_weather);
    tv_descript = (TextView) findViewById(R.id.tv_descript);


    handler = new Handler(this);
    tv_setting = (TextView) findViewById(R.id.tv_setting);
    tv_setting.setOnClickListener(this);
    tv_time.setOnClickListener(this);
    RelativeLayout rel_main = (RelativeLayout) findViewById(R.id.rel_main);
    rel_main.setOnClickListener(this);
    init();
    PowerManager powerManager = (PowerManager) this.getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "Clock");
    localWakeLock = powerManager.newWakeLock(32, "MyPower");

    ClockApplication.getInstance().setMainActivity(this);
    ClockApplication.getInstance().getBusinessService().getWeather(model.getCity());

    timer = new Timer();
    TimerTask timerTask = new TimerTask() {
        @Override
        public void run() {
            handler.sendEmptyMessage(UPDATE_TIME);
        }
    };
    timer.schedule(timerTask, 1000, 1000);
    ClockApplication.getInstance().getBusinessService().checkUpdate();
}
 
Example 6
Project: grafika   File: ChorTestActivity.java   View Source Code Vote up 5 votes
@Override
protected void onPause() {
    Log.d(TAG, "onPause");
    super.onPause();

    // if we get here too quickly, the handler might still be null; not dealing with that
    Handler handler = mRenderThread.getHandler();
    handler.sendEmptyMessage(0);
    mRenderThread = null;
}
 
Example 7
Project: letv   File: cccrcc.java   View Source Code Vote up 5 votes
public void notifyAuthorizationFailure() {
    Handler handler = this.b044E044E044E044Eюю;
    if (((b042904290429ЩЩЩ + b0429ЩЩ0429ЩЩ) * b042904290429ЩЩЩ) % b0429Щ04290429ЩЩ() != bЩЩЩ0429ЩЩ) {
        b042904290429ЩЩЩ = b04290429Щ0429ЩЩ();
        bЩЩЩ0429ЩЩ = 52;
    }
    handler.sendEmptyMessage(-1);
}
 
Example 8
Project: GitHub   File: QueuesHandler.java   View Source Code Vote up 4 votes
private void unFreezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_UNFREEZE);
}
 
Example 9
Project: airgram   File: VideoFrameReleaseTimeHelper.java   View Source Code Vote up 4 votes
private VSyncSampler() {
  choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler");
  choreographerOwnerThread.start();
  handler = new Handler(choreographerOwnerThread.getLooper(), this);
  handler.sendEmptyMessage(CREATE_CHOREOGRAPHER);
}
 
Example 10
Project: Android-LSS   File: MainActivity.java   View Source Code Vote up 4 votes
private void initUIHandler() {
    mUIEventHandler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case UI_EVNET_HIDE_LOADING_ANIMATION:
                mLoadingAnimation.setVisibility(View.GONE);
                mStartButton.setEnabled(true);
                break;
            case UI_EVENT_SHOW_STREAMING_ACTIVITY:
                /**
                 * 点击开始推流
                 */
                Intent intent = new Intent(MainActivity.this, StreamingActivity.class);
                /**保存摄像头方向*/
                saveStreamParams();
                /**推流地址*/
                intent.putExtra("push_url", mStreamKey.trim());
                /**推流视频宽度*/
                intent.putExtra("res_w", mSupportedResolutionValues[mSelectedResolutionIndex * 2]);
                /**推流视频高度*/
                intent.putExtra("res_h", mSupportedResolutionValues[mSelectedResolutionIndex * 2 + 1]);
                /**视频帧率*/
                intent.putExtra("frame_rate", mSupportedFramerateValues[mSelectedResolutionIndex]);
                /**视频码率*/
                intent.putExtra("bitrate", mSupportedBitrateValues[mSelectedResolutionIndex]);
                /**摄像头方向*/
                intent.putExtra("oritation_landscape", isOritationSwitcherChecked);
                startActivity(intent);
                break;
            case UI_EVENT_HINT_NO_STREAMING_URL:
                mStreamKey = mSharedPreferences.getString("user_avatar", "");
                Toast.makeText(MainActivity.this, "未获取到有效的推流地址,已使用上次推流的地址!", Toast.LENGTH_SHORT).show();
                mUIEventHandler.sendEmptyMessage(UI_EVENT_SHOW_STREAMING_ACTIVITY);
                break;
            default:
                break;
            }
            super.handleMessage(msg);
        }

    };

}
 
Example 11
Project: BluetoothAPP   File: SendSocketService.java   View Source Code Vote up 4 votes
/**
 * 发送文件
 */
public static void sendMessageByFile(Context context, Uri filePath, final Handler handler) {
    if (Comment.bluetoothSocket == null) {
        ToastUtil.showShort(context, "蓝牙连接失败...");
    }
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (Comment.bluetoothSocket == null || !Comment.bluetoothSocket.isConnected()) {
                Comment.bluetoothSocket = BluetoothUtil.connectDevice(handler);
            }
        }
    }).start();
    Dialog dialog = new DialogUtil.DefineDialog(context, 100, 0, filePath);
    dialog.show();
    try {
        File file = new File(filePath.toString());
        if (!file.exists()) return;
        //将文件写入流
        FileInputStream fis = new FileInputStream(file);
        //每次上传1M的内容
        byte[] b = new byte[1024];
        int length;
        int fileSize = 0;//实时监测上传进度

        OutputStream outputStream = Comment.bluetoothSocket.getOutputStream();
        while ((length = fis.read(b)) != -1) {
            fileSize += length;
            listenr.setProgress((int) (fileSize / file.length() * 100));
            //2、把文件写入socket输出流
            outputStream.write(b, 0, length);
        }
        //关闭文件流
        fis.close();
        //该方法无效
        //outputStream.write("\n".getBytes());
        outputStream.flush();
        handler.sendEmptyMessage(0);
    } catch (IOException e) {
        handler.sendEmptyMessage(1);
        e.printStackTrace();
    }
}
 
Example 12
Project: VideoRecorder-master   File: FFmpegRecorderActivity.java   View Source Code Vote up 4 votes
private void initHandler() {
    mHandler = new Handler() {
        @Override
        public void dispatchMessage(Message msg) {
            switch (msg.what) {
                case 2:
                    int resId = 0;
                    if (currentRecorderState == RecorderState.PRESS) {
                        resId = R.drawable.video_text01;
                    } else if (currentRecorderState == RecorderState.LOOSEN) {
                        resId = R.drawable.video_text02;
                    } else if (currentRecorderState == RecorderState.CHANGE) {
                        resId = R.drawable.video_text03;
                    } else if (currentRecorderState == RecorderState.SUCCESS) {
                        resId = R.drawable.video_text04;
                    }
                    stateImageView.setImageResource(resId);
                    break;
                case 3:
                    if (!recording)
                        initiateRecording(true);
                    else {
                        //更新暂停的时间
                        stopPauseTime = System.currentTimeMillis();
                        totalPauseTime = stopPauseTime - startPauseTime - ((long) (1.0 / (double) frameRate) * 1000);
                        pausedTime += totalPauseTime;
                    }
                    rec = true;
                    //开始进度条增长
                    progressView.setCurrentState(State.START);
                    //setTotalVideoTime();
                    break;
                case 4:
                    //设置进度条暂停状态
                    progressView.setCurrentState(State.PAUSE);
                    //将暂停的时间戳添加到进度条的队列中
                    progressView.putProgressList((int) totalTime);
                    rec = false;
                    startPauseTime = System.currentTimeMillis();
                    if (totalTime >= RECORDING_MINIMUM_TIME) {
                        currentRecorderState = RecorderState.SUCCESS;
                        mHandler.sendEmptyMessage(2);
                    } else if (totalTime >= RECORDING_CHANGE_TIME) {
                        currentRecorderState = RecorderState.CHANGE;
                        mHandler.sendEmptyMessage(2);
                    }
                    break;
                case 5:
                    currentRecorderState = RecorderState.SUCCESS;
                    mHandler.sendEmptyMessage(2);
                    break;
                default:
                    break;
            }
        }
    };
}
 
Example 13
Project: PlusGram   File: VideoFrameReleaseTimeHelper.java   View Source Code Vote up 4 votes
private VSyncSampler() {
  choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler");
  choreographerOwnerThread.start();
  handler = new Handler(choreographerOwnerThread.getLooper(), this);
  handler.sendEmptyMessage(CREATE_CHOREOGRAPHER);
}
 
Example 14
Project: FileDownloader-master   File: QueuesHandler.java   View Source Code Vote up 4 votes
private void freezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_FREEZE);
}
 
Example 15
Project: FileDownloader-master   File: QueuesHandler.java   View Source Code Vote up 4 votes
private void unFreezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_UNFREEZE);
}
 
Example 16
Project: Exoplayer2Radio   File: VideoFrameReleaseTimeHelper.java   View Source Code Vote up 4 votes
private VSyncSampler() {
  choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler");
  choreographerOwnerThread.start();
  handler = new Handler(choreographerOwnerThread.getLooper(), this);
  handler.sendEmptyMessage(CREATE_CHOREOGRAPHER);
}
 
Example 17
Project: RLibrary   File: QueuesHandler.java   View Source Code Vote up 4 votes
private void freezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_FREEZE);
}
 
Example 18
Project: RLibrary   File: QueuesHandler.java   View Source Code Vote up 4 votes
private void unFreezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_UNFREEZE);
}