草庐IT

background-position

全部标签

安卓 : how to know when an app enters or the "background" mode?

我正在尝试通过Android实现以下目标:当应用程序处于后台时,线程会时不时地轮询服务器以检索数据并在有新数据可用时通知用户。我正在为此使用服务,很好。当应用处于“Activity”使用状态时,即其Activity之一可见时,轮询应停止,因为它可能会干扰其他用户操作。我不明白如何检测应用程序“Activity”或“后台”使用之间的转换。onResume()Activity方法似乎没有帮助,因为无论如何在“Activity”使用期间Activity都可以隐藏或可见。我的理解是,应用程序本身并不能区分这两种状态。按下HOME键时可以关联吗?还有其他方法可以区分吗?我正在考虑等效于iPhon

android - 具有表面输入 : Recording in background 的 MediaCodec

我正在开发一个视频编码应用程序,我想防止它在托管Activity进入后台或屏幕循环关闭/打开时停止。我的编码器架构源自优秀的CameraToMpegTest例如,将相机帧显示到GLSurfaceView(参见下面的Github链接)。我目前正在使用双态解决方案进行后台录制:当宿主Activity在前台时,每次调用GLSurfaceView.Renderer的onDrawFrame时编码一个视频帧。这使我可以突发​​访问GLSurfaceView的EGL状态,以免阻塞排队到渲染器线程的其他事件。当托管Activity进入后台时,停止onDrawFrame编码并在循环内的另一个后台线程上对

android - 错误 : app is in background uid null

我在IntelliJCE2017.2上创建了一个新的Android项目并获得了thiserror.我按照答案中的描述添加了Maven部分。当我运行使用新项目创建的默认应用程序时出现错误Errorwhileexecuting:amstartservicecom.test.myapp/com.android.tools.fd.runtime.InstantRunServiceStartingservice:Intent{act=android.intent.action.MAINcat=[android.intent.category.LAUNCHER]cmp=com.test.myapp

android - 矢量绘图 : How to position it on canvas?

对于我的自定义View:MyCustomViewextendsView我制作了一个VectorDrawablemMyVectorDrawable=VectorDrawableCompat.create(getContext().getResources(),R.drawable.ic_some_image,null);我已经设置了它的界限mMyVectorDrawable.setBounds(0,0,mMyVectorDrawable.getIntrinsicWidth(),mMyVectorDrawable.getIntrinsicHeight());我把它画在Canvas上mMyV

Android - java.lang.IndexOutOfBoundsException : Invalid item position 0(0). 项目数:0

我在日志中收到此异常-java.lang.IndexOutOfBoundsException:Invaliditemposition0(0).Itemcount:0atandroid.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4622)atandroid.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)atcom.jivemap.app.CustomizedVi

android - 使用 Theme.MaterialComponents.Light.NoActionBar 样式时,设置 Button Background 无效

为了使用Chip和ChipGroup,我设置了ApplicationstyleextendsTheme.MaterialComponents.Light.NoActionBarintmanifests.xml,然后我设置了Button"android:background"属性,但它没有影响!为什么?我能做什么?这是我的风格:@color/primary_material_light@color/header_color48dpportrait@style/AntButton-->@style/AntButton-->-->@color/ffc000-->@color/ffc000@d

android - SearchView on support.v7.appcompat 库问题 : default 9-patch background not renders properly

我正在使用support.v7.appcompat库开发带有ActionBar的应用程序。操作栏有效,显示SearchView,提示显示。唯一的问题是SearchView的背景没有正确缩放。与往常不同的是,它显得很大,并带有9条黑色线条。使用:从命令行开发,使用antdebug编译。在LinuxMageia3上,ant版本:2013年1月11日编译的ApacheAnt(TM)版本1.8.4使用project.properties行链接到库:android.library.reference.1=../../../../../sdk/extras/android/support/v7/a

安卓工具栏 : how to have a toolbar with image in the background and menu items on top

如何使用MaterialDesign创建带有背景图片的工具栏。下面是我想要的:我正在尝试以下代码:我得到的是: 最佳答案 如果您坚持使用ImageView而不是使用.setBackground(...)函数。您可以尝试使用RelativeLayout和Toolbar覆盖ImageView,如下所示: 关于安卓工具栏:howtohaveatoolbarwithimageinthebackgroundandmenuitemsontop,我们在StackOverflow上找到一个类似的问题:

android - ?安卓 :attr/selectableItemBackground not visible enough on a dark background

在AndroidLollipop上,我使用:android:background="?android:attr/selectableItemBackground"当我点击一个按钮时获得Material动画反馈。当我在白色/浅色布局中包含一个按钮(例如CardView)时,效果很好。但是当我想在深色背景上使用同样的东西时,我们几乎看不到效果,它不够明显。有人有想法吗?谢谢 最佳答案 在API21+上,您可以设置android:theme="@android:style/ThemeOverlay.Material.Dark"在View上

android - 为什么Android的JSONArray中没有remove(int position)方法?

我开始构建一个使用平面文件进行存储的Android应用。该应用程序存储的记录不超过6条,而且我对JSON很熟悉,所以我只写了一个JSONArray到文件中。不过,我今天才发现,AndroidJSONAPI不包含remove()选项。嗯?我是否必须将数组转储到另一个集合中,删除它,然后重建JSONArray?有什么意义? 最佳答案 当你想直接使用json结构而不用循环转换时,这有时在android中很有用。请仅在执行长按删除行之类的操作时使用此功能。不要在循环中使用它!请注意,我仅在处理数组内的JSONObject时才使用它。publ