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


Java Handler.sendEmptyMessage方法代碼示例

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


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

示例1: connectDevice

import android.os.Handler; //導入方法依賴的package包/類
/**
     * 連接藍牙(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;
}
 
開發者ID:aiyangtianci,項目名稱:BluetoothAPP,代碼行數:24,代碼來源:BluetoothUtil.java

示例2: freezeSerialHandler

import android.os.Handler; //導入方法依賴的package包/類
private void freezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_FREEZE);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:QueuesHandler.java

示例3: updateClients

import android.os.Handler; //導入方法依賴的package包/類
public static void updateClients() {
	//myLog.l(Log.DEBUG, "UI update");
	//Log.d("UiUpdate", "Update now");
	for (Handler client : clients) {
		client.sendEmptyMessage(0);
	}
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:8,代碼來源:UiUpdater.java

示例4: getFolderAllImg

import android.os.Handler; //導入方法依賴的package包/類
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();
    }
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:28,代碼來源:MediaUtils.java

示例5: onCreate

import android.os.Handler; //導入方法依賴的package包/類
@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();
}
 
開發者ID:socoolby,項目名稱:CoolClock,代碼行數:39,代碼來源:MainActivity.java

示例6: onPause

import android.os.Handler; //導入方法依賴的package包/類
@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;
}
 
開發者ID:AndyZhu1991,項目名稱:grafika,代碼行數:11,代碼來源:ChorTestActivity.java

示例7: notifyAuthorizationFailure

import android.os.Handler; //導入方法依賴的package包/類
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);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:cccrcc.java

示例8: unFreezeSerialHandler

import android.os.Handler; //導入方法依賴的package包/類
private void unFreezeSerialHandler(Handler handler) {
    handler.sendEmptyMessage(WHAT_UNFREEZE);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:QueuesHandler.java

示例9: VSyncSampler

import android.os.Handler; //導入方法依賴的package包/類
private VSyncSampler() {
  choreographerOwnerThread = new HandlerThread("ChoreographerOwner:Handler");
  choreographerOwnerThread.start();
  handler = new Handler(choreographerOwnerThread.getLooper(), this);
  handler.sendEmptyMessage(CREATE_CHOREOGRAPHER);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:7,代碼來源:VideoFrameReleaseTimeHelper.java

示例10: initUIHandler

import android.os.Handler; //導入方法依賴的package包/類
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);
        }

    };

}
 
開發者ID:LiuJunb,項目名稱:Android-LSS,代碼行數:46,代碼來源:MainActivity.java

示例11: sendMessageByFile

import android.os.Handler; //導入方法依賴的package包/類
/**
 * 發送文件
 */
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();
    }
}
 
開發者ID:aiyangtianci,項目名稱:BluetoothAPP,代碼行數:46,代碼來源:SendSocketService.java

示例12: initHandler

import android.os.Handler; //導入方法依賴的package包/類
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;
            }
        }
    };
}
 
開發者ID:feigxj,項目名稱:VideoRecorder-master,代碼行數:58,代碼來源:FFmpegRecorderActivity.java


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