android.app.Activity.hasWindowFocus()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(457)

本文整理了Java中android.app.Activity.hasWindowFocus()方法的一些代码示例,展示了Activity.hasWindowFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.hasWindowFocus()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:hasWindowFocus

Activity.hasWindowFocus介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

public S hasWindowFocus() {
 isNotNull();
 assertThat(actual.hasWindowFocus()) //
   .overridingErrorMessage("Expected to have focus but was not focused.") //
   .isTrue();
 return myself;
}

代码示例来源:origin: com.uphyca/android-junit4-robolectric

/**
 * @return
 * @see android.app.Activity#hasWindowFocus()
 */
public boolean hasWindowFocus() {
  return mActivity.hasWindowFocus();
}

代码示例来源:origin: iqiyi/Neptune

@Override
public boolean hasWindowFocus() {
  return mOriginActivity.hasWindowFocus();
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public S hasWindowFocus() {
 isNotNull();
 assertThat(actual.hasWindowFocus()) //
   .overridingErrorMessage("Expected to have focus but was not focused.") //
   .isTrue();
 return myself;
}

代码示例来源:origin: com.jayway.android.robotium/robotium-core

/**
 * Returns the active DecorView. 
 * 
 * @return DecorView
 */

public View getActiveDecorView()
{
  final View [] views = getWindowDecorViews();
  final Activity activity = activityUtils.getCurrentActivity(false);
  if(views !=null && views.length > 0)
  {
    int length = views.length;
    for(int i = length - 1; i >= 0; i--){
    
      if(activity.hasWindowFocus() && getCurrentViews(TextView.class,(ViewGroup) views[i]).size()==1) {
        return views[i];
      }    
      else if(activity.hasWindowFocus() && activity.getWindow().getDecorView().equals(views[i])){
        return views[i];
      }
      else if(!activity.hasWindowFocus() && !activity.getWindow().getDecorView().equals(views[i])){ 
        return views[i];
      }
    }
    return views[views.length-1];
  }
  else
    return null;
}

代码示例来源:origin: jbruchanov/AnUitor

data.put("Title", activity.getTitle());
data.put("TitleColor", getStringColor(activity.getTitleColor()));
data.put("HasWindowFocus", activity.hasWindowFocus());
data.put("IsChild", activity.isChild());
data.put("IsDestroyed", activity.isFinishing());

代码示例来源:origin: blurpy/kouchat-android

public void test01LinksShouldWorkInTheMainChat() {
  RobotiumTestUtils.writeLine(solo, URL);
  solo.sleep(500);
  assertTrue(solo.getCurrentActivity().hasWindowFocus()); // KouChat is in focus
  RobotiumTestUtils.clickOnText(solo, R.id.mainChatView, R.id.mainChatScroll, URL);
  solo.sleep(1000);
  assertFalse(solo.getCurrentActivity().hasWindowFocus()); // Browser is in focus
  solo.sleep(3000); // Close browser manually now!
  RobotiumTestUtils.switchOrientation(solo);
  solo.sleep(2000);
  assertTrue(solo.getCurrentActivity().hasWindowFocus()); // KouChat is in focus
  RobotiumTestUtils.clickOnText(solo, R.id.mainChatView, R.id.mainChatScroll, URL);
  solo.sleep(1000);
  assertFalse(solo.getCurrentActivity().hasWindowFocus()); // Browser is in focus
}

代码示例来源:origin: blurpy/kouchat-android

public void test02LinksShouldWorkInThePrivateChat() {
  RobotiumTestUtils.openPrivateChat(solo, getInstrumentation(), 2, 2, "Test");
  RobotiumTestUtils.writeLine(solo, URL);
  solo.sleep(500);
  assertTrue(solo.getCurrentActivity().hasWindowFocus()); // KouChat is in focus
  RobotiumTestUtils.clickOnText(solo, R.id.privateChatView, R.id.privateChatScroll, URL);
  solo.sleep(1000);
  assertFalse(solo.getCurrentActivity().hasWindowFocus()); // Browser is in focus
  solo.sleep(3000); // Close browser manually now!
  RobotiumTestUtils.switchOrientation(solo);
  solo.sleep(2000);
  assertTrue(solo.getCurrentActivity().hasWindowFocus()); // KouChat is in focus
  RobotiumTestUtils.clickOnText(solo, R.id.privateChatView, R.id.privateChatScroll, URL);
  solo.sleep(1000);
  assertFalse(solo.getCurrentActivity().hasWindowFocus()); // Browser is in focus
}

相关文章

Activity类方法