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


Java SystemClock.sleep方法代码示例

本文整理汇总了Java中android.os.SystemClock.sleep方法的典型用法代码示例。如果您正苦于以下问题:Java SystemClock.sleep方法的具体用法?Java SystemClock.sleep怎么用?Java SystemClock.sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.SystemClock的用法示例。


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

示例1: start

import android.os.SystemClock; //导入方法依赖的package包/类
public void start() throws IOException {
    if (DEBUG) Log.d(TAG, "Start");
    if (mStarted) return;

    // Keep an exception, in case data is requested before it is available;
    mLastException = new IOException("No data available");

    // Begin listening for interrupt events
    mDevice.registerUartDeviceCallback(mUartCallback, mHandler);

    // Turn on autosend (to get regular sensor readings)
    sendCommand(CMD_START_PARTICLE_MEASUREMENT);
    SystemClock.sleep(20);
    sendCommand(CMD_ENABLE_AUTO_SEND);
    mStarted = true;
}
 
开发者ID:jpuderer,项目名称:jpuderer-things-drivers,代码行数:17,代码来源:HpmSensor.java

示例2: clickRedPacketAfter

import android.os.SystemClock; //导入方法依赖的package包/类
/** 查看领取详情或者返回 */
private void clickRedPacketAfter() {
    // 到这, 领取流程算是完了
    isReceived = false;

    // 查看领取详情, 或者返回
    if(!config().isSmartBackQQ()){
        SystemClock.sleep(999);
        AccessibilityNodeInfo nodeInfo = mService.getRootInActiveWindow();
        if(nodeInfo == null) {
            LogUtils.printErr(TAG, "rootWindow为空");
            return;
        }

        AccessibilityNodeInfo look = AccessibilityUtils.findNodeInfosByText(nodeInfo, KEY_LOOK);
        if(look != null){
            AccessibilityUtils.performClick(look);
        }
    }else{
        back();
    }
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:23,代码来源:QQAccessibilityJob.java

示例3: sendTestMessage

import android.os.SystemClock; //导入方法依赖的package包/类
private void sendTestMessage(Message.Type messageType, Challenge.Type challengeType, boolean createChallenge) {
    // Send message
    Message msg1 = new Message("runnest_dot_ihl_at_gmail_dot_com",
            "Test User",
            "Runnest IHL",
            "Test User",
            messageType,
            "test1",
            new Date(),
            1,
            0,
            challengeType);

    FirebaseHelper firebaseHelper = new FirebaseHelper();
    firebaseHelper.sendMessage(msg1);

    if(createChallenge) {
        // Instantiate challenges so that messages are clickable
        firebaseHelper.addChallengeNode("Test User", "Runnest IHL", "Runnest IHL vs Test User test1");
    }

    // Needed to be sure that the sent message appears on firebase
    SystemClock.sleep(FIREBASE_DURATION);
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:25,代码来源:MessageTest.java

示例4: unlockScreen

import android.os.SystemClock; //导入方法依赖的package包/类
@Before
public void unlockScreen() {
    final Activity activity = mActivityRule.getActivity();
    Runnable wakeUpDevice = new Runnable() {
        public void run() {
            activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
                    WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                    WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        }
    };
    activity.runOnUiThread(wakeUpDevice);
    SystemClock.sleep(500);
}
 
开发者ID:Visions-Team,项目名称:eBread,代码行数:14,代码来源:SettingThemeFragmentTest.java

示例5: uncaughtException

import android.os.SystemClock; //导入方法依赖的package包/类
/**
 * 捕获异常回掉
 *
 * @param thread 当前线程
 * @param ex     异常信息
 */
@Override
public void uncaughtException(Thread thread, Throwable ex) {
        //导出异常信息到SD卡
       File file=dumpExceptionToSDCard(ex);
        //上传异常信息到服务器
        uploadExceptionToServer(ex,file);
        //延时1秒杀死进程
        SystemClock.sleep(2000);
        Process.killProcess(Process.myPid());
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:17,代码来源:CrashHandler.java

示例6: getSplashBg

import android.os.SystemClock; //导入方法依赖的package包/类
@DoBack
private void getSplashBg() throws IOException {
    fuli = RetrofitHelper.getAPI().randomGirl( 1);
    Response<ResponseInfo<Information>> response = fuli.execute();
    if (response.isSuccessful()) {
        setSplashBg(response.body().getResults().get(0).getUrl());
    } else {
        toast("网络请求失败");
    }
    SystemClock.sleep(2000);
    startActivity(new Intent(this,MainActivity.class));
    finish();
}
 
开发者ID:penghongru,项目名称:Coder,代码行数:14,代码来源:SplashActivity.java

示例7: crazyAcquireContentProvider

import android.os.SystemClock; //导入方法依赖的package包/类
public static ContentProviderClient crazyAcquireContentProvider(Context context, Uri uri) {
    ContentProviderClient client = acquireContentProviderClient(context, uri);
    if (client == null) {
        int retry = 0;
        while (retry < 5 && client == null) {
            SystemClock.sleep(100);
            retry++;
            client = acquireContentProviderClient(context, uri);
        }
    }
    return client;
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:13,代码来源:ContentProviderCompat.java

示例8: retryRequest

import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean retry = true;

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b);

    if (executionCount > maxRetries) {
        // Do not retry if over max retry count
        retry = false;
    } else if (isInList(exceptionWhitelist, exception)) {
        // immediately retry if error is whitelisted
        retry = true;
    } else if (isInList(exceptionBlacklist, exception)) {
        // immediately cancel retry if the error is blacklisted
        retry = false;
    } else if (!sent) {
        // for most other errors, retry only if request hasn't been fully sent yet
        retry = true;
    }

    if (retry) {
        // resend all idempotent requests
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
        if (currentReq == null) {
            return false;
        }
    }

    if (retry) {
        SystemClock.sleep(retrySleepTimeMS);
    } else {
        exception.printStackTrace();
    }

    return retry;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:38,代码来源:RetryHandler.java

示例9: todayWeatherFragmentShouldNotifyViewModelAboutFragmentDestruction

import android.os.SystemClock; //导入方法依赖的package包/类
@Test
public void todayWeatherFragmentShouldNotifyViewModelAboutFragmentDestruction() throws Exception {
    rule.launchActivity(null);
    reset(todayVm);
    device().setOrientationLeft();
    SystemClock.sleep(300);
    verify(todayVm).onViewDetached();
}
 
开发者ID:aschattney,项目名称:dagger-test-example,代码行数:9,代码来源:WeatherFragmentTest.java

示例10: crazyAcquireContentProvider

import android.os.SystemClock; //导入方法依赖的package包/类
public static ContentProviderClient crazyAcquireContentProvider(Context context, String name) {
    ContentProviderClient client = acquireContentProviderClient(context, name);
    if (client == null) {
        int retry = 0;
        while (retry < 5 && client == null) {
            SystemClock.sleep(100);
            retry++;
            client = acquireContentProviderClient(context, name);
        }
    }
    return client;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:13,代码来源:ContentProviderCompat.java

示例11: retryRequest

import android.os.SystemClock; //导入方法依赖的package包/类
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean sent;
    boolean retry = true;
    Boolean b = (Boolean) context.getAttribute("http.request_sent");
    if (b == null || !b.booleanValue()) {
        sent = false;
    } else {
        sent = true;
    }
    if (executionCount > this.maxRetries) {
        retry = false;
    } else if (isInList(exceptionWhitelist, exception)) {
        retry = true;
    } else if (isInList(exceptionBlacklist, exception)) {
        retry = false;
    } else if (!sent) {
        retry = true;
    }
    if (retry && ((HttpUriRequest) context.getAttribute("http.request")) == null) {
        return false;
    }
    if (retry) {
        SystemClock.sleep((long) this.retrySleepTimeMS);
    } else {
        exception.printStackTrace();
    }
    return retry;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:RetryHandler.java

示例12: getFavoriteBooks

import android.os.SystemClock; //导入方法依赖的package包/类
public List<String> getFavoriteBooks() {
    SystemClock.sleep(8000);// "Simulate" the delay of network.
    return createBooks();
}
 
开发者ID:vogellacompany,项目名称:code-examples-android-expert,代码行数:5,代码来源:RestClient.java

示例13: getAllContactInfo

import android.os.SystemClock; //导入方法依赖的package包/类
/**
 * 获取手机联系人
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_CONTACTS"/>}</p>
 *
 * @return 联系人链表
 */
public static List<HashMap<String, String>> getAllContactInfo() {
    SystemClock.sleep(3000);
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
    // 1.获取内容解析者
    ContentResolver resolver = Utils.getApp().getContentResolver();
    // 2.获取内容提供者的地址:com.android.contacts
    // raw_contacts表的地址 :raw_contacts
    // view_data表的地址 : data
    // 3.生成查询地址
    Uri raw_uri = Uri.parse("content://com.android.contacts/raw_contacts");
    Uri date_uri = Uri.parse("content://com.android.contacts/data");
    // 4.查询操作,先查询raw_contacts,查询contact_id
    // projection : 查询的字段
    Cursor cursor = resolver.query(raw_uri, new String[]{"contact_id"}, null, null, null);
    try {
        // 5.解析cursor
        if (cursor != null) {
            while (cursor.moveToNext()) {
                // 6.获取查询的数据
                String contact_id = cursor.getString(0);
                // cursor.getString(cursor.getColumnIndex("contact_id"));//getColumnIndex
                // : 查询字段在cursor中索引值,一般都是用在查询字段比较多的时候
                // 判断contact_id是否为空
                if (!StringUtils.isEmpty(contact_id)) {//null   ""
                    // 7.根据contact_id查询view_data表中的数据
                    // selection : 查询条件
                    // selectionArgs :查询条件的参数
                    // sortOrder : 排序
                    // 空指针: 1.null.方法 2.参数为null
                    Cursor c = resolver.query(date_uri, new String[]{"data1",
                                    "mimetype"}, "raw_contact_id=?",
                            new String[]{contact_id}, null);
                    HashMap<String, String> map = new HashMap<String, String>();
                    // 8.解析c
                    if (c != null) {
                        while (c.moveToNext()) {
                            // 9.获取数据
                            String data1 = c.getString(0);
                            String mimetype = c.getString(1);
                            // 10.根据类型去判断获取的data1数据并保存
                            if (mimetype.equals("vnd.android.cursor.item/phone_v2")) {
                                // 电话
                                map.put("phone", data1);
                            } else if (mimetype.equals("vnd.android.cursor.item/name")) {
                                // 姓名
                                map.put("name", data1);
                            }
                        }
                    }
                    // 11.添加到集合中数据
                    list.add(map);
                    // 12.关闭cursor
                    if (c != null) {
                        c.close();
                    }
                }
            }
        }
    } finally {
        // 12.关闭cursor
        if (cursor != null) {
            cursor.close();
        }
    }
    return list;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:74,代码来源:PhoneUtils.java

示例14: onCreate

import android.os.SystemClock; //导入方法依赖的package包/类
public void onCreate() {
    super.onCreate();
    SystemClock.sleep(1000);
}
 
开发者ID:GlugMVIT,项目名称:GLUG_MVIT_APP,代码行数:5,代码来源:SplashScreen_ColdStart.java

示例15: getAllContactInfo

import android.os.SystemClock; //导入方法依赖的package包/类
/**
 * 获取手机联系人
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>}</p>
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.READ_CONTACTS"/>}</p>
 *
 * @return 联系人链表
 */
public static List<HashMap<String, String>> getAllContactInfo() {
    SystemClock.sleep(3000);
    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
    // 1.获取内容解析者
    ContentResolver resolver = Utils.getContext().getContentResolver();
    // 2.获取内容提供者的地址:com.android.contacts
    // raw_contacts表的地址 :raw_contacts
    // view_data表的地址 : data
    // 3.生成查询地址
    Uri raw_uri = Uri.parse("content://com.android.contacts/raw_contacts");
    Uri date_uri = Uri.parse("content://com.android.contacts/data");
    // 4.查询操作,先查询raw_contacts,查询contact_id
    // projection : 查询的字段
    Cursor cursor = resolver.query(raw_uri, new String[]{"contact_id"}, null, null, null);
    try {
        // 5.解析cursor
        if (cursor != null) {
            while (cursor.moveToNext()) {
                // 6.获取查询的数据
                String contact_id = cursor.getString(0);
                // cursor.getString(cursor.getColumnIndex("contact_id"));//getColumnIndex
                // : 查询字段在cursor中索引值,一般都是用在查询字段比较多的时候
                // 判断contact_id是否为空
                if (!StringUtils.isEmpty(contact_id)) {//null   ""
                    // 7.根据contact_id查询view_data表中的数据
                    // selection : 查询条件
                    // selectionArgs :查询条件的参数
                    // sortOrder : 排序
                    // 空指针: 1.null.方法 2.参数为null
                    Cursor c = resolver.query(date_uri, new String[]{"data1",
                                    "mimetype"}, "raw_contact_id=?",
                            new String[]{contact_id}, null);
                    HashMap<String, String> map = new HashMap<String, String>();
                    // 8.解析c
                    if (c != null) {
                        while (c.moveToNext()) {
                            // 9.获取数据
                            String data1 = c.getString(0);
                            String mimetype = c.getString(1);
                            // 10.根据类型去判断获取的data1数据并保存
                            if (mimetype.equals("vnd.android.cursor.item/phone_v2")) {
                                // 电话
                                map.put("phone", data1);
                            } else if (mimetype.equals("vnd.android.cursor.item/name")) {
                                // 姓名
                                map.put("name", data1);
                            }
                        }
                    }
                    // 11.添加到集合中数据
                    list.add(map);
                    // 12.关闭cursor
                    if (c != null) {
                        c.close();
                    }
                }
            }
        }
    } finally {
        // 12.关闭cursor
        if (cursor != null) {
            cursor.close();
        }
    }
    return list;
}
 
开发者ID:pan2yong22,项目名称:AndroidUtilCode-master,代码行数:74,代码来源:PhoneUtils.java


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