当前位置: 首页>>代码示例>>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;未经允许,请勿转载。