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


Java HandlerThread类代码示例

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


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

示例1: WebRTCModule

import android.os.HandlerThread; //导入依赖的package包/类
public WebRTCModule(ReactApplicationContext reactContext) {
    super(reactContext);

    imageProcessingThread = new HandlerThread("PictureProcessing");
    imageProcessingThread.start();
    imagePorcessingHandler = new Handler(imageProcessingThread.getLooper());

    mPeerConnectionObservers = new SparseArray<PeerConnectionObserver>();
    mMediaStreams = new HashMap<String, MediaStream>();
    mMediaStreamTracks = new HashMap<String, MediaStreamTrack>();
    mVideoCapturers = new HashMap<String, VideoCapturer>();
    mCameras = new HashMap<>();

    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"));
    pcConstraints.mandatory.add(new MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"));
    pcConstraints.optional.add(new MediaConstraints.KeyValuePair("DtlsSrtpKeyAgreement", "true"));

    PeerConnectionFactory.initializeAndroidGlobals(reactContext, true, true, true);
    mFactory = new PeerConnectionFactory();
}
 
开发者ID:angellsl10,项目名称:react-native-webrtc,代码行数:21,代码来源:WebRTCModule.java

示例2: stopDraw

import android.os.HandlerThread; //导入依赖的package包/类
private void stopDraw() {
    DrawHandler handler = this.handler;
    this.handler = null;
    unlockCanvasAndPost();
    if (handler != null) {
        handler.quit();
    }
    if (this.mHandlerThread != null) {
        HandlerThread handlerThread = this.mHandlerThread;
        this.mHandlerThread = null;
        try {
            handlerThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        handlerThread.quit();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:19,代码来源:DanmakuView.java

示例3: init

import android.os.HandlerThread; //导入依赖的package包/类
private void init() {
    if (isAndroidThingsDevice(this)) {
        initPIO();
    }

    mBackgroundThread = new HandlerThread("BackgroundThread");
    mBackgroundThread.start();
    mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
    mBackgroundHandler.post(mInitializeOnBackground);

    // Let the user touch the screen to take a photo
    findViewById(R.id.container).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mReady.get()) {
                Log.i(TAG, "Taking photo");
                setReady(false);
                mBackgroundHandler.post(mBackgroundClickHandler);
            } else {
                Log.i(TAG, "Sorry, processing hasn't finished. Try again in a few seconds");
            }
        }
    });
}
 
开发者ID:androidthings,项目名称:sample-tensorflow-imageclassifier,代码行数:25,代码来源:ImageClassifierActivity.java

示例4: stopDraw

import android.os.HandlerThread; //导入依赖的package包/类
private void stopDraw() {
    if (this.handler != null) {
        this.handler.quit();
        this.handler = null;
    }
    if (this.mHandlerThread != null) {
        HandlerThread handlerThread = this.mHandlerThread;
        this.mHandlerThread = null;
        try {
            handlerThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        handlerThread.quit();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:17,代码来源:DanmakuTextureView.java

示例5: onCreate

import android.os.HandlerThread; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    setContentView(R.layout.scan_activity);
    scannerView = (ScannerView) findViewById(R.id.scan_activity_mask);
    previewView = (TextureView) findViewById(R.id.scan_activity_preview);
    previewView.setSurfaceTextureListener(this);

    cameraThread = new HandlerThread("cameraThread", Process.THREAD_PRIORITY_BACKGROUND);
    cameraThread.start();
    cameraHandler = new Handler(cameraThread.getLooper());

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, 0);
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:19,代码来源:ScanActivity.java

示例6: onCreate

import android.os.HandlerThread; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    mHandlerThread = new HandlerThread(getClass().getSimpleName());
    mHandlerThread.start();
    mDbHandler = new Handler(mHandlerThread.getLooper());
    mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);

    setTheme(android.R.style.Theme_Holo_Light_NoActionBar);

    mSessions = new ArrayList<>();
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(TvInputManager.ACTION_BLOCKED_RATINGS_CHANGED);
    intentFilter.addAction(TvInputManager.ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED);
    registerReceiver(mParentalControlsBroadcastReceiver, intentFilter);
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:17,代码来源:RichTvInputService.java

示例7: startBackgroundThread

import android.os.HandlerThread; //导入依赖的package包/类
/**
 * Starts a background thread and its {@link Handler}.
 */
private void startBackgroundThread() {
    mBackgroundThread = new HandlerThread("CameraBackground");
    mBackgroundThread.start();
    mBackgroundHandler = new Handler(mBackgroundThread.getLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case MSG_CAPTURE_PICTURE_WHEN_FOCUS_TIMEOUT:
                    mState = STATE_PICTURE_TAKEN;
                    captureStillPicture();
                    break;
                default:
                    break;
            }

        }
    };
}
 
开发者ID:lytcom,项目名称:CameraKitView,代码行数:23,代码来源:Camera2Fragment.java

示例8: a

import android.os.HandlerThread; //导入依赖的package包/类
public a(int i, boolean z, h hVar, b bVar) {
    super(i, z, hVar);
    this.i = false;
    a(bVar);
    this.e = new g();
    this.f = new g();
    this.g = this.e;
    this.h = this.f;
    this.d = new char[bVar.f()];
    bVar.b();
    g();
    this.j = new HandlerThread(bVar.c(), bVar.h());
    if (this.j != null) {
        this.j.start();
    }
    if (this.j.isAlive() && this.j.getLooper() != null) {
        this.k = new Handler(this.j.getLooper(), this);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:a.java

示例9: open

import android.os.HandlerThread; //导入依赖的package包/类
public void open() {
    try {
        CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
        for (String cameraId : manager.getCameraIdList()) {
            CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);
            if (characteristics.get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_BACK) {
                StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
                mCameraSize = map.getOutputSizes(SurfaceTexture.class)[0];

                HandlerThread thread = new HandlerThread("OpenCamera");
                thread.start();
                Handler backgroundHandler = new Handler(thread.getLooper());

                manager.openCamera(cameraId, mCameraDeviceCallback, null);

                // カメラの物理的な情報を得る
                mCameraCharacteristics = manager.getCameraCharacteristics( cameraId );
                return;
            }
        }
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:25,代码来源:Camera2.java

示例10: UltrasonicSensorDriver

import android.os.HandlerThread; //导入依赖的package包/类
/**
 * Public constructor.
 *
 * @param triggerPin Name of the trigger pin
 * @param echoPin    Name of the echo pin
 * @param listener   {@link DistanceListener} to get callbacks when distance changes.
 */
public UltrasonicSensorDriver(@NonNull String triggerPin, @NonNull String echoPin, DistanceListener listener) {
    PeripheralManagerService service = new PeripheralManagerService();

    try {
        setTriggerPin(service, triggerPin);
        setEchoPin(service, echoPin);
    } catch (IOException e) {
        e.printStackTrace();
        throw new IllegalArgumentException("Invalid pin name.");
    }

    //Set callback listener.
    mListener = listener;
    if (mListener == null)
        throw new IllegalArgumentException("DistanceListener cannot be null.");

    //Start sending pulses
    //We are using different thread for sending pulses to increase time accuracy.
    HandlerThread triggerHandlerThread = new HandlerThread("TriggerHandlerThread");
    triggerHandlerThread.start();
    mTriggerHandler = new Handler(triggerHandlerThread.getLooper());
    mTriggerHandler.post(mTriggerRunnable);
}
 
开发者ID:kevalpatel2106,项目名称:collision-detector-android-things,代码行数:31,代码来源:UltrasonicSensorDriver.java

示例11: onCreate

import android.os.HandlerThread; //导入依赖的package包/类
@Override
public void onCreate() {
    // Start up the thread running the service.  Note that we create a
    // separate thread because the service normally runs in the process's
    // main thread, which we don't want to block.  We also make it
    // background priority so CPU-intensive work will not disrupt our UI.
    HandlerThread thread = new HandlerThread("ServiceStartArguments",
            Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();

    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotificationMap = new SparseIntArray();

    // Get the HandlerThread's Looper and use it for our Handler
    mServiceLooper = thread.getLooper();
    //mServiceHandler = new ServiceHandler(mServiceLooper);
    mServiceHandler = new ServiceHandler(mServiceLooper, this);
    setPrefs(PreferenceManager.getDefaultSharedPreferences(this));
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:20,代码来源:ManualAnimeUpdaterService.java

示例12: onCreate

import android.os.HandlerThread; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.zcps = getSharedPreferences("reg", 0);
    setContentView(R.layout.activity_main);
    findView();
    this.shouquanqqTextView.setText("正版注册授权QQ:" + getString(R.string.zhuceqq));
    getPrefparas();
    showPrefparas();
    startService(new Intent(this, PhoneService.class));
    this.startLayout.setVisibility(View.VISIBLE);
    new HandlerThread("myHandlerThread").start();
    this.handler = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0) {
                MainActivity.this.startLayout.setVisibility(View.INVISIBLE);
                MainActivity.this.gonggaoLayout.setVisibility(View.VISIBLE);
                MainActivity.this.mainlLayout.setVisibility(View.INVISIBLE);
            }
        }
    };
    this.tt.run();
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:23,代码来源:MainActivity.java

示例13: d

import android.os.HandlerThread; //导入依赖的package包/类
private d() {
    try {
        HandlerThread handlerThread = new HandlerThread("StatDispatcher");
        handlerThread.start();
        d = handlerThread.getId();
        this.b = new Handler(handlerThread.getLooper());
        HttpParams basicHttpParams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(basicHttpParams, 10000);
        HttpConnectionParams.setSoTimeout(basicHttpParams, 10000);
        this.a = new DefaultHttpClient(basicHttpParams);
        this.a.setKeepAliveStrategy(new e(this));
        if (StatConfig.b() != null) {
            this.a.getParams().setParameter("http.route.default-proxy", StatConfig.b());
        }
    } catch (Object th) {
        c.e(th);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:d.java

示例14: LCIMLocalStorage

import android.os.HandlerThread; //导入依赖的package包/类
public LCIMLocalStorage(Context context, String clientId, String tableName) {
  super(context, DB_NAME_PREFIX, null, DB_VERSION);

  if (TextUtils.isEmpty(tableName)) {
    throw new IllegalArgumentException("tableName can not be null");
  }
  if (TextUtils.isEmpty(clientId)) {
    throw new IllegalArgumentException("clientId can not be null");
  }

  final String md5ClientId = AVUtils.md5(clientId);
  this.tableName = tableName + "_" + md5ClientId;

  createTable();

  readDbThread = new HandlerThread("LCIMLocalStorageReadThread");
  readDbThread.start();
  readDbHandler = new Handler(readDbThread.getLooper());
}
 
开发者ID:linsir6,项目名称:TripBuyer,代码行数:20,代码来源:LCIMLocalStorage.java

示例15: onCreate

import android.os.HandlerThread; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    log("onCreate");

    // First init the Client
    Application application = getApplication();
    if (application instanceof OSCApplication) {
        OSCApplication.reInit();
    }

    HandlerThread thread = new HandlerThread(TweetPublishService.class.getSimpleName());
    thread.start();

    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
    mReceiver = ListenAccountChangeReceiver.start(this);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:19,代码来源:TweetPublishService.java


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