草庐IT

Activity3

全部标签

java - ExecutorService 中的 Activity 线程

关于如何确定ExecutorService中当前运行的Activity线程数的任何想法? 最佳答案 使用ThreadPoolExecutor实现并调用getActiveCount()就可以了:intgetActiveCount()//Returnstheapproximatenumberofthreadsthatareactivelyexecutingtasks.ExecutorService接口(interface)没有为此提供方法,它取决于实现。 关于java-ExecutorSer

java - ExecutorService 中的 Activity 线程

关于如何确定ExecutorService中当前运行的Activity线程数的任何想法? 最佳答案 使用ThreadPoolExecutor实现并调用getActiveCount()就可以了:intgetActiveCount()//Returnstheapproximatenumberofthreadsthatareactivelyexecutingtasks.ExecutorService接口(interface)没有为此提供方法,它取决于实现。 关于java-ExecutorSer

java - 如何在 Spring 通过注释设置 Activity 配置文件?

如何在spring中通过注释设置Activity配置文件?例如:@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ApplicationConfig.class},loader=AnnotationConfigContextLoader.class)@ActiveProfiles(profiles={ApplicationProfiles.TEST})publicclassCacheManagerTest{...}对于JUnit测试,这很完美,但我如何初始化生产应用程序上下文?(我没有任何主要方法

java - 如何在 Spring 通过注释设置 Activity 配置文件?

如何在spring中通过注释设置Activity配置文件?例如:@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={ApplicationConfig.class},loader=AnnotationConfigContextLoader.class)@ActiveProfiles(profiles={ApplicationProfiles.TEST})publicclassCacheManagerTest{...}对于JUnit测试,这很完美,但我如何初始化生产应用程序上下文?(我没有任何主要方法

android - 屏幕关闭时开始 Activity

我已经设置了一个AlarmManager来启动一个Activity。此Activity还会播放声音,类似于闹钟应用或来电。如果屏幕打开,即使屏幕被锁定,它也能正常工作。如果屏幕关闭,则它根本不起作用。我尝试使用以下内容作为onCreate中的第一件事getWindow().setFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON,WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);如果未启用屏幕锁定,这会打开屏幕,我可以看到我的Activity正在关闭。我听不到播放的声音。如果启用了屏幕锁

java - AsycTask 抛出 IllegalStateException - fragment 未附加到 Activity

我的Android应用程序中有以下AsyncTask。此AsyncTask包含在扩展PreferenceFragment的类的OnCreate()方法中。publicclassNotificationsPreferenceFragmentextendsPreferenceFragment{privatestaticContextcontext;publicNotificationsPreferenceFragment(){}publicNotificationsPreferenceFragment(Contextcontext){this.context=context;}@Overr

android - 如何在登录时向登录 Activity 添加进度条?

我正在创建一个应用程序来登录parse.com,然后浏览项目和其他功能,但我无法添加进度条或任何类似的东西,所以当应用程序正在登录时,什么也没有发生,我只是在等待它登录进入并转移到其他Activity这是我的登录代码,请帮忙importandroid.app.Activity;importandroid.content.Intent;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.widget.Button;importandroi

android - 主屏幕的 Activity 透明背景不是最后一个 Activity

我正在从android.intent.action.CALLIntent启动一个Activity。我想展示一个类似于带有透明背景进度对话框的布局(而我在移交给native拨号器之前进行处理)。但是在可见的背景后面应该是主屏幕。目前Activity加载正常,所需加载对话框之外的背景是透明的,但显示的不是背景中的主屏幕,而是最后一个应用程序屏幕/Activity。如何强制我的透明背景成为主屏幕? 最佳答案 为此,只需将list文件中的android主题设置为“Theme.Wallpaper”即:还要确保为Activity设置透明背景。例

android - 如何在 Activity 的 OnCreate() 方法中调用 findViewWithTag?

当我在onCreate()中调用findViewWithTag()时出现错误"ThemethodfindViewWithTag(String)isundefinedforthetypeMainActivity"还有其他选择吗? 最佳答案 findViewWithTag()仅为View定义。如果您有对使用setContentView(contentView)设置的Activity的contentView的引用,则可以使用contentView.findViewWithTag()。如果您没有对该View的引用,您也可以使用findVie

Android:防止 Activity 被多次实例化

我正在浏览AndroidTaskandBackStackdocumentation有一次他们提到了这一点:ifyourapplicationallowsuserstostartaparticularactivityfrommorethanoneactivity,anewinstanceofthatactivityiscreatedandpushedontothestack(ratherthanbringinganypreviousinstanceoftheactivitytothetop).Assuch,oneactivityinyourapplicationmightbeinstan