本文整理了Java中android.app.Activity.<init>()
方法的一些代码示例,展示了Activity.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.<init>()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:<init>
暂无
代码示例来源:origin: stackoverflow.com
final Crouton crouton = Crouton.makeText(new Activity(), "foo", Style.ALERT)
.setConfiguration(new Configuration.Builder().setDuration(Configuration.DURATION_INFINITE).build());
crouton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Crouton.hide(crouton);
}
});
crouton.show();
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCallFinishOnFinish() {
Activity activity = new Activity();
activity.finish();
assertTrue(activity.isFinishing());
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Before
public void setUp() throws Exception {
mActivity = new Activity();
// Make and set view with some prelim values to test
mView = new TestImageView(mActivity);
mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
mImageAware = new ImageViewAware(mView);
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = JELLY_BEAN)
public void shouldCallFinishOnFinishAffinity() {
Activity activity = new Activity();
activity.finishAffinity();
assertTrue(activity.isFinishing());
}
代码示例来源:origin: robolectric/robolectric
@Test
@Config(minSdk = LOLLIPOP)
public void shouldCallFinishOnFinishAndRemoveTask() {
Activity activity = new Activity();
activity.finishAndRemoveTask();
assertTrue(activity.isFinishing());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getErrorDialog() {
assertNotNull(GooglePlayServicesUtil.getErrorDialog(
ConnectionResult.SERVICE_MISSING, new Activity(), 0));
assertNull(GooglePlayServicesUtil.getErrorDialog(
ConnectionResult.SUCCESS, new Activity(), 0));
assertNotNull(GooglePlayServicesUtil.getErrorDialog(
ConnectionResult.SERVICE_MISSING, new Activity(), 0, null));
assertNull(GooglePlayServicesUtil.getErrorDialog(
ConnectionResult.SUCCESS, new Activity(), 0, null));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCallFinishInOnBackPressed() {
Activity activity = new Activity();
activity.onBackPressed();
assertTrue(activity.isFinishing());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getAndSetParentActivity_shouldWorkForTestingPurposes() throws Exception {
Activity parentActivity = new Activity();
Activity activity = new Activity();
shadowOf(activity).setParent(parentActivity);
assertSame(parentActivity, activity.getParent());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testCreateInstance() {
assertThat(CookieSyncManager.createInstance(new Activity())).isNotNull();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldReturnSameApplicationEveryTime() throws Exception {
Activity activity = new Activity();
assertThat(activity.getApplication()).isSameAs(activity.getApplication());
assertThat(activity.getApplication()).isSameAs(new Activity().getApplication());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void extractor() throws Exception {
Activity activity = new Activity();
assertThat((ShadowActivity) Shadow.extract(activity)).isSameAs(shadowOf(activity));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void otherDeprecated_extractor() throws Exception {
Activity activity = new Activity();
assertThat(Shadow.<Object>extract(activity)).isSameAs(shadowOf(activity));
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testGetInstance() {
CookieSyncManager.createInstance(new Activity());
assertThat(CookieSyncManager.getInstance()).isNotNull();
}
}
代码示例来源:origin: f2prateek/dart
@Test
public void bindingKnownPackagesIsNoOp() {
bind(new Activity());
bindNavigationModel(new Object(), new Activity());
assertThat(EXTRA_BINDERS).isEmpty();
assertThat(NAVIGATION_MODEL_BINDERS).isEmpty();
}
}
代码示例来源:origin: robolectric/robolectric
@Before
public void setUp() throws Exception {
am = AccountManager.get(ApplicationProvider.getApplicationContext());
scheduler = Robolectric.getForegroundThreadScheduler();
activity = new Activity();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getAndSetRequestedOrientation_shouldRemember() throws Exception {
Activity activity = new Activity();
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, activity.getRequestedOrientation());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getCurrentActivity_shouldReturnTheProvidedCurrentActivity() throws Exception {
ActivityGroup activityGroup = new ActivityGroup();
Activity activity = new Activity();
shadowOf(activityGroup).setCurrentActivity(activity);
assertThat(activityGroup.getCurrentActivity()).isSameAs(activity);
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getAndSetRequestedOrientation_shouldDelegateToParentIfPresent() throws Exception {
Activity parentActivity = new Activity();
Activity activity = new Activity();
shadowOf(activity).setParent(parentActivity);
parentActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
assertEquals(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, activity.getRequestedOrientation());
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
assertEquals(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE, parentActivity.getRequestedOrientation());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void setDefaultKeyMode_shouldSetKeyMode() {
int[] modes = {
Activity.DEFAULT_KEYS_DISABLE,
Activity.DEFAULT_KEYS_SHORTCUT,
Activity.DEFAULT_KEYS_DIALER,
Activity.DEFAULT_KEYS_SEARCH_LOCAL,
Activity.DEFAULT_KEYS_SEARCH_GLOBAL
};
Activity activity = new Activity();
ShadowActivity shadow = shadowOf(activity);
for (int mode : modes) {
activity.setDefaultKeyMode(mode);
assertThat(shadow.getDefaultKeymode()).named("Unexpected key mode").isEqualTo(mode);
}
}
代码示例来源:origin: aws-amplify/aws-sdk-android
@Before
public void setUp() throws Exception {
if (!initCompleted) {
r = new Random();
credentialsProvider = new CognitoCachingCredentialsProvider(new Activity(), IDENTITY_POOL_ID, Regions.US_EAST_1);
iotClient = new AWSIotClient(credentialsProvider);
DescribeEndpointRequest request = new DescribeEndpointRequest();
DescribeEndpointResult result = iotClient.describeEndpoint(request);
endpointPrefix = result.getEndpointAddress().split("\\.")[0];
initCompleted = true;
}
}
内容来源于网络,如有侵权,请联系作者删除!