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


Java Looper.loop方法代碼示例

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


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

示例1: provide

import android.os.Looper; //導入方法依賴的package包/類
@Override
protected void provide() {
    Looper.prepare();
    locationManager = (LocationManager) this.getContext().getSystemService(Context.LOCATION_SERVICE);
    locationListener = new MyLocationListener();

    long minTime = 0;
    float minDistance = 0;
    String provider;
    if (Geolocation.LEVEL_EXACT.equals(level)) {
        provider = LocationManager.GPS_PROVIDER;
    }
    else {
        provider = LocationManager.NETWORK_PROVIDER;
    }
    locationManager.requestLocationUpdates(provider, minTime, minDistance, locationListener);
    Looper.loop();
}
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:19,代碼來源:CurrentLocationProvider.java

示例2: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
    mRuntime.loopers.prepare();
    mTimer = new Timer(mRuntime.bridges, mMaxCallbackUptimeMillisForAllThreads);
    sTimerMap.put(Thread.currentThread(), mTimer);
    notifyRunning();
    new Handler().post(mTarget);
    try {
        Looper.loop();
    } catch (Exception e) {
        if (!ScriptInterruptedException.causedByInterrupted(e)) {
            mRuntime.console.error(Thread.currentThread().toString() + ": " + e);
        }
    } finally {
        onExit();
        mTimer = null;
        sTimerMap.remove(Thread.currentThread(), mTimer);
    }
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:20,代碼來源:TimerThread.java

示例3: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
  Looper.prepare();
  handler = new DecodeHandler(activity, hints);
  handlerInitLatch.countDown();
  Looper.loop();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:8,代碼來源:DecodeThread.java

示例4: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
  Looper.prepare();
  handler = new DecodeHandler(mIScanCallback, hints);
  handlerInitLatch.countDown();
  Looper.loop();
}
 
開發者ID:10045125,項目名稱:QrCode,代碼行數:8,代碼來源:DecodeThread.java

示例5: testCreateInitialRealm

import android.os.Looper; //導入方法依賴的package包/類
public void testCreateInitialRealm() throws InterruptedException {
    new InterprocessHandler(new Runnable() {
        @Override
        public void run() {
            // Step 1
            testRealm = Realm.getInstance(new RealmConfiguration.Builder(getContext()).build());
            assertEquals(0, testRealm.where(AllTypes.class).count());
            testRealm.beginTransaction();
            testRealm.createObject(AllTypes.class);
            testRealm.commitTransaction();

            // Step A
            triggerServiceStep(RemoteProcessService.stepCreateInitialRealm_A);
        }
    }) {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == RemoteProcessService.stepCreateInitialRealm_A.message) {
                clearTimeoutFlag();
                done();
            } else {
                assertTrue(false);
            }
        }
    };
    Looper.loop();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:30,代碼來源:RealmInterprocessTest.java

示例6: run

import android.os.Looper; //導入方法依賴的package包/類
public void run() {
    Looper.prepare();
    synchronized (this) {
        this.mLooper = Looper.myLooper();
        notifyAll();
    }
    Process.setThreadPriority(10);
    Looper.loop();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:DownloadEngine.java

示例7: start

import android.os.Looper; //導入方法依賴的package包/類
public static Thread start(final Actionable actionable) {
Thread t=new Thread(new Runnable(){
	public void run() {
	  actionable.doInThread();
	  Looper.prepare();
	  actionable.callback();
	  Looper.loop();
	}
  });
t.start();
return t;
 }
 
開發者ID:TIIEHenry,項目名稱:TIIEHenry-Android-SDK,代碼行數:13,代碼來源:Task.java

示例8: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
  Looper.prepare();
  handler = new Handler();
  startedSignal.countDown();
  Looper.loop();
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:8,代碼來源:Camera2CapturerTest.java

示例9: initLooperThread

import android.os.Looper; //導入方法依賴的package包/類
public void initLooperThread() {
    stopLooperThread();
    looperThread = new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            Looper.prepare();
            backgroundHandlerLooper = Looper.myLooper();
            backgroundThreadHandler = new Handler();
            Looper.loop();
        }
    });
    looperThread.start();
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:16,代碼來源:MainActivity.java

示例10: uncaughtException

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void uncaughtException(Thread t, Throwable e) {
   Looper.prepare();
    StringBuffer sb=new StringBuffer();
    StackTraceElement[] stackTrace = e.getStackTrace();
    for (StackTraceElement stackTraceElement : stackTrace) {
        sb.append(stackTraceElement.toString());
        sb.append("\nfile:  ");
        sb.append(stackTraceElement.getFileName());
        sb.append("\nclass:   ");
        sb.append(stackTraceElement.getClassName());
        sb.append("\nmethod:   ");
        sb.append(stackTraceElement.getMethodName());
        sb.append("\nline:   ");
        sb.append(stackTraceElement.getLineNumber());
        sb.append("\n—————————————————\n");
    }
    Toast.makeText(MyApplication.getContext(),"Oops!出現錯誤!\n已將錯誤日誌複製到粘貼板,請向作者反饋\n\n"+sb,Toast.LENGTH_LONG).show();
    Toast.makeText(MyApplication.getContext(),"Oops!出現錯誤!\n已將錯誤日誌複製到粘貼板,請向作者反饋\n\n"+sb,Toast.LENGTH_LONG).show();
    ClipboardManager cmb = (ClipboardManager)MyApplication.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    cmb.setText(sb);

    //android.os.Process.killProcess(android.os.Process.myPid());
    //System.exit(0);
    Looper.loop();



}
 
開發者ID:Delsart,項目名稱:Bookster,代碼行數:30,代碼來源:MyCrashHandler.java

示例11: run

import android.os.Looper; //導入方法依賴的package包/類
@Override
public void run() {
  Looper         looper   = initializeLooper();
  ListenCallback callback = new ListenCallback(looper);

  TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
  telephonyManager.listen(callback, PhoneStateListener.LISTEN_SERVICE_STATE);

  Looper.loop();

  telephonyManager.listen(callback, PhoneStateListener.LISTEN_NONE);

  set(callback.isConnected());
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:15,代碼來源:TelephonyServiceState.java

示例12: AndroidExecutorImpl

import android.os.Looper; //導入方法依賴的package包/類
@Inject
AndroidExecutorImpl(Application app) {
	uiHandler = new Handler(app.getApplicationContext().getMainLooper());
	loop = new Runnable() {
		@Override
		public void run() {
			Looper.prepare();
			backgroundHandler = new Handler();
			startLatch.countDown();
			Looper.loop();
		}
	};
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:14,代碼來源:AndroidExecutorImpl.java

示例13: upLoadInfo

import android.os.Looper; //導入方法依賴的package包/類
/**
 * 上傳信息
 * @param realName 真實姓名
 * @param idCode 身份證號
 * @param schoolCode 學號
 * @param idUp 身份證正麵
 * @param idDown 身份證背麵
 * @param schCard 校園卡背麵
 */
private void upLoadInfo(final String realName, final String idCode, final String schoolCode, final String idUp,
                        final String idDown, final String schCard) {
    startUploadDialog();
    uploadThread = new Thread(new Runnable() {
        @Override
        public void run() {
            Looper.prepare();
            String response = "";
            try {
                BasicHttpParams httpParams = new BasicHttpParams();
                HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
                HttpConnectionParams.setSoTimeout(httpParams, 5000);

                HttpClient httpclient = new DefaultHttpClient(httpParams);

                //服務器地址,指向Servlet
                HttpPost httpPost = new HttpPost(ServerUtil.SLVerification);

                List<NameValuePair> params = new ArrayList<NameValuePair>();//將數據裝入list
                params.add(new BasicNameValuePair("realname", realName));
                params.add(new BasicNameValuePair("idcode", idCode));
                params.add(new BasicNameValuePair("schoolcode", schoolCode));
                params.add(new BasicNameValuePair("idup", idUp));
                params.add(new BasicNameValuePair("iddown", idDown));
                params.add(new BasicNameValuePair("schoolcard", schCard));
                params.add(new BasicNameValuePair("userid", userIntent.getUserId()));

                final UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "utf-8");//以UTF-8格式發送
                httpPost.setEntity(entity);
                //對提交數據進行編碼
                HttpResponse httpResponse = httpclient.execute(httpPost);
                if (httpResponse.getStatusLine().getStatusCode() == 200)//在5000毫秒之內接收到返回值
                {
                    HttpEntity entity1 = httpResponse.getEntity();
                    response = EntityUtils.toString(entity1, "utf-8");//以UTF-8格式解析
                    Message message = mHandler.obtainMessage();
                        message.what = 0;
                        message.obj = response;
                        mHandler.handleMessage(message);
                } else {
                    Message message = mHandler.obtainMessage();
                    message.what = 1;
                    mHandler.handleMessage(message);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Message message = mHandler.obtainMessage();
                message.what = 1;
                mHandler.handleMessage(message);
            }
            Looper.loop();
        }
    });
    uploadThread.start();
}
 
開發者ID:838030195,項目名稱:DaiGo,代碼行數:65,代碼來源:VerificationActivity.java

示例14: checkUserInfoFromDatabase

import android.os.Looper; //導入方法依賴的package包/類
public void checkUserInfoFromDatabase(final String disCode,final String phoneNum, final String passwd) {
    startLoginDialog();
    user.setPhoneNum(phoneNum);
    user.setPassword(passwd);
    checkThread = new Thread(new Runnable() {
        @Override
        public void run() {
            Looper.prepare();
            try {
                BasicHttpParams httpParams = new BasicHttpParams();
                HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
                HttpConnectionParams.setSoTimeout(httpParams, 5000);

                HttpClient httpclient = new DefaultHttpClient(httpParams);

                //服務器地址,指向Servlet
                HttpPost httpPost = new HttpPost(ServerUtil.SLLogin);

                List<NameValuePair> params = new ArrayList<NameValuePair>();//將數據裝入list
                params.add(new BasicNameValuePair("discode", disCode));
                params.add(new BasicNameValuePair("phonenum", phoneNum));
                params.add(new BasicNameValuePair("password", passwd));
                final UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "utf-8");//以UTF-8格式發送
                httpPost.setEntity(entity);
                //對提交數據進行編碼
                HttpResponse httpResponse = httpclient.execute(httpPost);
                if(httpResponse.getStatusLine().getStatusCode()==200)//在5000毫秒之內接收到返回值
                {
                    HttpEntity entity1 = httpResponse.getEntity();
                    response = EntityUtils.toString(entity1, "utf-8");//以UTF-8格式解析
                    Message message = handler.obtainMessage();
                    message.what = 0;
                    message.obj = response;
                    handler.handleMessage(message);
                } else {
                    Message message = handler.obtainMessage();
                    message.what = 1;
                    handler.handleMessage(message);
                }
            } catch (Exception e) {
                e.printStackTrace();
                Message message = handler.obtainMessage();
                message.what = 1;
                handler.handleMessage(message);
            }
            Looper.loop();

        }

    });
    checkThread.start();
}
 
開發者ID:838030195,項目名稱:DaiGo,代碼行數:53,代碼來源:LoginActivity.java

示例15: initThread

import android.os.Looper; //導入方法依賴的package包/類
private void initThread() {
    mThread = new Thread(new Runnable() {
        @Override
        public void run() {
        Looper.prepare();

        int count = 0;
        String str = "";
        try {
            //execute the command
            final Process process = Runtime.getRuntime().exec(cmd);
            BufferedReader reader = new BufferedReader(new InputStreamReader(
                    process.getInputStream()));

            //handler that can stop the thread
            mHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                process.destroy();

                mThread.interrupt();
                mThread = null;

                try {
                    process.waitFor();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                }
            };

            //read the lines
            int i;
            final char[] buffer = new char[4096];
            StringBuffer output = new StringBuffer();

            while ((i = reader.read(buffer)) > 0) {
                output.append(buffer, 0, i);

                Handler h = new Handler(Looper.getMainLooper());
                final int finalI = i;
                h.post(new Runnable() {
                    @Override
                    public void run() {
                        ReturnObject o = new ReturnObject();
                        o.put("value", finalI + " " + String.valueOf(buffer));
                        callbackfn.event(o);
                    }
                });

            }
            reader.close();

            str = output.toString();
        } catch (IOException e) {
            // Log.d(TAG, "Error");
            e.printStackTrace();
        }
        Looper.loop();
        }

    });
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:64,代碼來源:ExecuteCmd.java


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