本文整理汇总了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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例12: getFavoriteBooks
import android.os.SystemClock; //导入方法依赖的package包/类
public List<String> getFavoriteBooks() {
SystemClock.sleep(8000);// "Simulate" the delay of network.
return createBooks();
}
示例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;
}
示例14: onCreate
import android.os.SystemClock; //导入方法依赖的package包/类
public void onCreate() {
super.onCreate();
SystemClock.sleep(1000);
}
示例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;
}