當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。