Example usage for android.os HandlerThread start

List of usage examples for android.os HandlerThread start

Introduction

In this page you can find the example usage for android.os HandlerThread start.

Prototype

public synchronized void start() 

Source Link

Document

Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.

Usage

From source file:com.cssweb.android.quote.KLine2Activity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD");
    mHandlerThread.start();
    mHandler = new MessageHandler(mHandlerThread.getLooper());

    this.activityKind = Global.QUOTE_KLINE;

    Bundle bundle = getIntent().getExtras();
    this.exchange = bundle.getString("exchange");
    this.stockcode = bundle.getString("stockcode");
    this.stockname = bundle.getString("stockname");
    CssSystem.exchange = bundle.getString("exchange");
    CssSystem.stockcode = bundle.getString("stockcode");
    CssSystem.stockname = bundle.getString("stockname");

    cssStock = new CssStock();
    cssStock.setMarket(this.exchange);
    cssStock.setStkcode(this.stockcode);
    cssStock.setStkname(this.stockname);

    setContentView(R.layout.zr_klineview2);

    //      toolbarname = new String[]{ 
    //            Global.TOOLBAR_MENU, Global.TOOLBAR_ZHIBIAO, 
    //            Global.TOOLBAR_ZHOUQI, Global.TOOLBAR_F10, 
    //            Global.TOOLBAR_ZOOMOUT, Global.TOOLBAR_ZOOMIN };
    toolbarname = new String[] { Global.TOOLBAR_MENU, Global.TOOLBAR_FENSHI, Global.TOOLBAR_ZHOUQI,
            Global.TOOLBAR_ZHIBIAO, Global.TOOLBAR_F10, Global.TOOLBAR_REFRESH };

    if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setToolbarByScreen(2);// ww  w . j  a  v a2 s.  c om
    } else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        setToolbarByScreen(1);
    }

    initTitle(R.drawable.njzq_title_left_back, 0, "K");

    setTitleText(stockname + " " + peroidN);

    initKlineView();

    getZhibiao();
    getZhouqi();
}

From source file:org.durka.hallmonitor.CoreService.java

@Override
public void onCreate() {
    Log.d(LOG_TAG + ".oC", "Core service creating");
    localCoreService = this;

    mStateManager = ((CoreApp) getApplicationContext()).getStateManager();

    Log.d(LOG_TAG + ".oC", "Register special actions");
    mStateManager.registerCoreService(this);

    mStateManager.registerCoreReceiver();

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();

    // Get the HandlerThread's Looper and use it for our Handler
    mTouchCoverLooper = thread.getLooper();
    mTouchCoverHandler = new TouchCoverHandler(mTouchCoverLooper);
    lastTouchCoverRequest = mStateManager.getCoverClosed();

    try {//from  w w  w .  j  a  v  a  2s  . c  o  m
        startActivityAsUser = ((ContextWrapper) this).getClass().getMethod("startActivityAsUser", Intent.class,
                UserHandle.class);
        Log.d(LOG_TAG, "startActivityAsUser registred");
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }

    launchDefaultActivity = new Intent(localCoreService, DefaultActivity.class)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    mUserHandle = android.os.Process.myUserHandle();
}

From source file:org.disrupted.rumble.network.NetworkCoordinator.java

@Override
public void onCreate() {
    super.onCreate();
    synchronized (lock) {
        Log.d(TAG, "[+] Starting NetworkCoordinator");
        HandlerThread serviceThread = new HandlerThread("NetworkCoordinatorThread",
                android.os.Process.THREAD_PRIORITY_BACKGROUND);
        serviceThread.start();
        serviceLooper = serviceThread.getLooper();
        serviceHandler = new Handler(serviceLooper);
        serviceHandler.post(new Runnable() {
            @Override/*from   www.jav  a 2s  . com*/
            public void run() {
                neighbourManager = new NeighbourManager();
                scannerList = new LinkedList<Scanner>();

                // register link layers and their pool
                adapters = new LinkedList<LinkLayerAdapter>();
                workerPools = new HashMap<String, WorkerPool>();
                BluetoothLinkLayerAdapter bluetoothLinkLayerAdapter = BluetoothLinkLayerAdapter
                        .getInstance(NetworkCoordinator.this);
                adapters.add(bluetoothLinkLayerAdapter);
                workerPools.put(BluetoothLinkLayerAdapter.LinkLayerIdentifier, new WorkerPool(5));
                WifiLinkLayerAdapter wifiAdapter = new WifiLinkLayerAdapter();
                adapters.add(wifiAdapter);
                workerPools.put(wifiAdapter.getLinkLayerIdentifier(), new WorkerPool(10));

                // register protocols
                protocols = new LinkedList<Protocol>();
                protocols.add(RumbleProtocol.getInstance(NetworkCoordinator.this));
                //protocols.add(FirechatProtocol.getInstance(this));

                // register services
                services = new LinkedList<ServiceLayer>();
                services.add(PushService.getInstance(NetworkCoordinator.this));
                services.add(ChatService.getInstance(NetworkCoordinator.this));

                networkingStarted = false;
                EventBus.getDefault().register(NetworkCoordinator.this);
            }
        });
    }
}

From source file:com.digitalarx.android.files.services.FileDownloader.java

/**
 * Service initialization//from  w w w.  j  av  a 2  s  .c o m
 */
@Override
public void onCreate() {
    super.onCreate();
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    HandlerThread thread = new HandlerThread("FileDownloaderThread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper, this);
    mBinder = new FileDownloaderBinder();
}

From source file:de.stadtrallye.rallyesoft.services.UploadService.java

@Override
public void onCreate() {
    super.onCreate();

    notes = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    connection = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
    telephony = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    connection.getActiveNetworkInfo();/*from   w ww . j ava 2  s.co m*/

    Storage.aquireStorage(getApplicationContext(), this);
    dbProvider = Storage.getDatabaseProvider();
    pictureManager = Storage.getPictureManager();

    pref = Storage.getAppPreferences();
    pref.registerOnSharedPreferenceChangeListener(this);

    readPrefs();

    HandlerThread thread = new HandlerThread("UploadService [UploadThread]");
    thread.start();

    looper = thread.getLooper();
    handler = new UploaderHandler(looper);
}

From source file:com.android.camera.manager.ThumbnailViewManager.java

@Override
public void begin() {
    Log.i(TAG, "[begin]...");
    if (mWorkerHandler == null) {
        HandlerThread t = new HandlerThread("thumbnail-creation-thread");
        t.start();
        mWorkerHandler = new WorkerHandler(t.getLooper());
    }/*from  w  w  w  . ja v a  2 s  .  c o  m*/
}

From source file:com.hmsoft.weargoproremote.services.WearMessageHandlerService.java

@Override
public void onCreate() {
    super.onCreate();
    if (Logger.DEBUG)
        Logger.debug(TAG, "Service created");

    HandlerThread executorThread = new HandlerThread("WearMessageHandlerService");
    executorThread.start();
    mExecutorLooper = executorThread.getLooper();
    mWorkHandler = new Handler(mExecutorLooper, this);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    mPass = mPrefs.getString(getString(R.string.preference_wifi_password_key), "");
    mPreviewEnabled = mPrefs.getBoolean(getString(R.string.preference_watch_preview_enabled_key), true);
    mGoProController = GoProController.getDefaultInstance(mPass);
    mPrefs.registerOnSharedPreferenceChangeListener(this);

    mSendStatusTimer = new Timer(60000, mWorkHandler, new Timer.TimerTask() {
        @Override//from w  w  w .j a va  2  s  . c  om
        public void onTick(int ticks) {
            sendCameraStatus();
            if (BuildConfig.DEBUG)
                Logger.debug(TAG, "Status sent...");
        }
    });

    updateNotification(getString(R.string.status_connection_starting));
}

From source file:com.cssweb.android.quote.FenLei.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    HandlerThread mHandlerThread = new HandlerThread("CSSWEB_THREAD");
    mHandlerThread.start();
    mHandler = new MessageHandler(mHandlerThread.getLooper());

    Bundle bundle = getIntent().getExtras();
    this.requestType = bundle.getInt("requestType");
    this.activityKind = Global.QUOTE_FENLEI;
    requestParams = new RequestParams();
    requestParams.setMarket("SHSZA");
    requestParams.setPaixu("zqdm");
    setContentView(R.layout.zr_table);//from  w w  w. ja  v  a  2 s  .c  o  m

    String[] toolbarname = new String[] { Global.TOOLBAR_MENU, Global.TOOLBAR_PINGZHONG, Global.TOOLBAR_PAIXU,
            Global.TOOLBAR_SHANGYE, Global.TOOLBAR_XIAYIYE, Global.TOOLBAR_REFRESH };

    initTitle(R.drawable.njzq_title_left_back, 0, "");
    initToolBar(toolbarname, Global.BAR_TAG);

    cols = getResources().getStringArray(R.array.stock_cols);

    menu = getResources().getStringArray(R.array.stock_type_menu);
    paiming = getResources().getStringArray(R.array.zqpm_menu);
    desc = getResources().getStringArray(R.array.stock_desc);
    //A
    title1 = menu[6];
    //title2 = paiming[0];

    //????
    allStockNums = StockInfo.getStockInfoSize(stocktype);
    pageNum = CssSystem.getTablePageSize(FenLei.this);
    rowHeight = CssSystem.getTableRowHeight(FenLei.this);
    openOption();

    openPopup();

    requestParams.setBegin("1");
    requestParams.setEnd(String.valueOf(pageNum));
    setToolBar(3, false, R.color.zr_newlightgray);

    init(2);
}

From source file:net.xisberto.phonetodesktop.GoogleTasksActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Configure a background thread
    HandlerThread thread = new HandlerThread("PhoneToDesktopThread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    looper = thread.getLooper();/*  w w w .  j av a 2 s  .  co  m*/
    handler = new Handler(looper);

    // Configure app's preferences
    settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    accountManager = new GoogleAccountManager(getApplicationContext());

    // Configure GoogleCredential. loadAuthToken can return null
    credential = new GoogleCredential();
    log("Current saved token: " + loadAuthToken());

    // Configure and build the Tasks object
    tasksService = new Tasks.Builder(transport, jsonFactory, credential).setApplicationName("PhoneToDesktop")
            .setJsonHttpRequestInitializer(new GoogleKeyInitializer(my_credentials.getAPIKey())).build();

    if (getIntent().getAction().equals(ACTION_AUTHENTICATE)) {
        broadcastUpdatingStatus(ACTION_AUTHENTICATE, true);
        authorize();
    } else if (getIntent().getAction().equals(Intent.ACTION_SEND)) {
        addTask(loadWhatToSend(), getIntent().getStringExtra(Intent.EXTRA_TEXT));
    } else if (getIntent().getAction().equals(ACTION_LIST_TASKS)) {
        broadcastUpdatingStatus(ACTION_LIST_TASKS, true);
        getTaskList();
    } else if (getIntent().getAction().equals(ACTION_REMOVE_TASKS)) {
        removeTask(getIntent().getStringExtra("task_id"));
    }

}

From source file:com.wlanjie.streaming.camera.CameraView.java

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    GLES20.glDisable(GL10.GL_DITHER);//www.  ja v a2 s. co m
    GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    HandlerThread thread = new HandlerThread("glDraw");
    thread.start();
    mHandler = new Handler(thread.getLooper()) {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            IntBuffer buffer = mEglCore.getRgbaBuffer();
            mFrameBuffer.asIntBuffer().put(buffer.array());
            if (mCallback != null) {
                mCallback.onPreviewFrame(CameraView.this, mFrameBuffer.array());
            }
        }
    };

    mEglCore = new EglCore(getResources());
    mEglCore.init();

    mSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
        @Override
        public void onFrameAvailable(SurfaceTexture surfaceTexture) {
            mGLSurfaceView.requestRender();
        }
    });
}