android

toArray with pre sized array

≡放荡痞女 提交于 2021-02-18 10:49:08
问题 when using ar.toArray(new String[ar.size()]) Android studio 3.2.1 warns about pre-sized array and recommends empty array : There are two styles to convert a collection to an array: either using a pre-sized array (like c.toArray(new String[c.size()])) or using an empty array (like c.toArray(new String[0]). In older Java versions using pre-sized array was recommended, as the reflection call which is necessary to create an array of proper size was quite slow. However since late updates of

How to get rid of the program name bar at the top of the application?

爱⌒轻易说出口 提交于 2021-02-18 10:01:53
问题 i would like to get rid of the defualt grey bar which apears at the top of my application. I just can't seem to find the attribute or setting to do so. how can this be achived? thanks 回答1: Use android:theme="@android:style/Theme.NoTitleBar" , either for this specific <activity> element in your manifest, or for the whole <application> element if you want it gone for all of them. Here's a FAQ entry about it. 回答2: I tried the manifest method but for some reason it wasn't working. However using

How to get rid of the program name bar at the top of the application?

人走茶凉 提交于 2021-02-18 10:01:43
问题 i would like to get rid of the defualt grey bar which apears at the top of my application. I just can't seem to find the attribute or setting to do so. how can this be achived? thanks 回答1: Use android:theme="@android:style/Theme.NoTitleBar" , either for this specific <activity> element in your manifest, or for the whole <application> element if you want it gone for all of them. Here's a FAQ entry about it. 回答2: I tried the manifest method but for some reason it wasn't working. However using

How to Pass POJO class in Work manager in android?

ぐ巨炮叔叔 提交于 2021-02-18 09:58:46
问题 How can we pass Serializable object in work manager by setData method of work manager? Is there any way to process with Work manager by passing object? WorkManager is a library used to enqueue work that is guaranteed to execute after its constraints are met. WorkManager allows observation of work status and the ability to create complex chains of work. Map<String, Object> map = new HashMap<>(); AddressBookData addressBookData = new AddressBookData(); addressBookData.setThreadId(001); map.put(

iOS Abort问题系统性解决方案

做~自己de王妃 提交于 2021-02-18 08:55:34
一、背景 崩溃(Crash),即闪退,多指移动设备(如iOS、Android设备)在打开/使用应用程序的过程中,突然出现意外退出/中断的情况。如果App线上版本频繁发生崩溃,会极大地影响用户体验,甚至导致用户流失,以及收益减少。因此,崩溃问题是客户端稳定性团队需要重点解决的问题。 然而,对于所有崩溃场景,仅25%的崩溃可通过信号量捕获,实施相应改进;另有75%的崩溃则难以识别,从而对App的用户体验,造成了巨大的潜在影响。 Facebook的工程师将App退出分为以下6个类别: 1.App内部主动调用exit()或abort()退出; 2.App升级过程中,用户进程被杀死; 3.系统升级过程中,用户进程被杀死; 4.App在后台被杀死; 5.App在前台被杀死,且可获取堆栈; 6.App在前台被杀死,且无法获取堆栈。 对于第1~4类退出,属于App的正常退出,对用户体验没有太大影响,无需进行相应处理;对于第5类退出,可通过堆栈代码级定位崩溃原因,对此业界已形成比较成熟的解决方案,推荐免费试用 阿里云的崩溃分析服务 ,即可快速定位、解决此类崩溃问题;对于第6类退出,可能的原因很多,包括但不限于:系统内存不足时继续申请内存、主线程卡死20s以上、CPU使用率过高Stack Overflow等,在此我们统一称之为iOS客户端的“Abort问题”。 Abort问题无法被堆栈捕获

DialogFragment.dismiss crashing with NullPointerException

ε祈祈猫儿з 提交于 2021-02-18 08:54:41
问题 I'm doing some background work and showing a DialogFragment while I do that. Once my work is done and the relevant callback is invoked, I dismiss the dialog. When I do, I get a crash caused by a NPE in the android source, here: void dismissInternal(boolean allowStateLoss) { if (mDialog != null) { mDialog.dismiss(); mDialog = null; } mRemoved = true; if (mBackStackId >= 0) { getFragmentManager().popBackStack(mBackStackId, FragmentManager.POP_BACK_STACK_INCLUSIVE); mBackStackId = -1; } else {

Get ID of currently open camera

只谈情不闲聊 提交于 2021-02-18 08:52:54
问题 How can I get the ID of the currently open android camera from an android camera instance? I can't see it in the parameters and getCameraInfo requires the id as a parameter. 回答1: There isn't a way to get the id of the currently open android camera. I ended up storing the id when I opened it. 回答2: It is just a number of the camera, so you loop through looking for the camera you want. Here is a snippet to find the front-facing camera: int cameraId = -1; int numberOfCameras = Camera

Can't fetch expanded URL from a given shortened URL

末鹿安然 提交于 2021-02-18 08:48:41
问题 I am given a shortened url and I want to get the expanded form. The below java function is used to achieve this. public String expand(String shortenedUrl){ URL url = null; try { url = new URL(shortenedUrl); } catch (MalformedURLException e) { e.printStackTrace(); } // open connection HttpURLConnection httpURLConnection = null; try { httpURLConnection = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY); } catch (IOException e) { e.printStackTrace(); } // stop following browser redirect

SurfaceTexture AttachToGLContext and Surface

只谈情不闲聊 提交于 2021-02-18 08:48:31
问题 I'm trying to find out whether I need to remake a Surface if I want to call the attachToGLContext method from a SurfaceTexture. I tried to look in the android documentation, but there is no mention. I'm guessing not because as far as I'm aware, Surface is a buffer for a SurfaceTexture which can act as an external texture for an OpenGL context. So attaching the SurfaceTexture to a different context should not affect this. Does anybody know for sure? 回答1: The internal name for SurfaceTexture is

Can't fetch expanded URL from a given shortened URL

橙三吉。 提交于 2021-02-18 08:48:09
问题 I am given a shortened url and I want to get the expanded form. The below java function is used to achieve this. public String expand(String shortenedUrl){ URL url = null; try { url = new URL(shortenedUrl); } catch (MalformedURLException e) { e.printStackTrace(); } // open connection HttpURLConnection httpURLConnection = null; try { httpURLConnection = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY); } catch (IOException e) { e.printStackTrace(); } // stop following browser redirect