android

ext4/fsync situation unclear in Android (Java)

孤人 提交于 2021-02-17 08:48:26
问题 Tim Bray's article "Saving Data Safely" left me with open questions. Today, it's over a month old and I haven't seen any follow-up on it, so I decided to address the topic here. One point of the article is that FileDescriptor.sync() should be called to be on the safe side when using FileOutputStream. At first, I was very irritated, because I never have seen any Java code doing a sync during the 12 years I do Java. Especially since coping with files is a pretty basic thing. Also, the standard

ConstraintLayout max width percentage

▼魔方 西西 提交于 2021-02-17 08:46:24
问题 I've been experimenting with ConstraintLayout, is there a way to set the max width of a view to a percentage of the parent (and a height of match constraint and dimension ratio of 1:1)? Here is the code without using max width: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content">

ConstraintLayout max width percentage

只愿长相守 提交于 2021-02-17 08:46:12
问题 I've been experimenting with ConstraintLayout, is there a way to set the max width of a view to a percentage of the parent (and a height of match constraint and dimension ratio of 1:1)? Here is the code without using max width: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content">

Android toolbar elevation when scrolling

泪湿孤枕 提交于 2021-02-17 08:44:56
问题 I try to implement a search bar like in google maps android app: When the recycler view is in its initial state, the toolbar has no elevation. Only when the users starts scrolling the elevation becomes visible. And the search bar (toolbar) never collapses. Here is what I tried to replicate this: <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <android.support.v7.widget.RecyclerView

Why is RxJava often used with Retrofit?

谁说我不能喝 提交于 2021-02-17 08:36:50
问题 What is the benefit of using Retrofit in combination with Rxjava? 回答1: Question Retrofit Already in run on background thread. Then why need another background task RxJava? I think most importanly, avoid nested callbacks( callback hell ). e.g) Callback hell (Retrofit) public interface MyService { @GET("users") Call<List<UserModel>> getUser(); @GET("userinfo") Call<UserInfoModel> getUserInfoById(@Query("id") Integer id); } service.getUser().enqueue(new Callback<UserModel>() { @Override public

Chrome Inspect不显示Webview页面的问题总结

空扰寡人 提交于 2021-02-17 07:58:00
首先,确保手机打开了USB调试。如果还是检测不到WebView页面,主要有以下几种情况。 1、反应慢,稍等一会 2、关闭然后重新打开USB调试开关,刺激一下chrome,我的魅族手机有时需要这样操作一下。 3、华为手机,打开USB调试和 仅充电模式下允许ADB调试。 如下图所示: 如果还不行,请安装华为手机助手,插上手机后会提示安装的。不安装的话,可能会出现不稳定的情况。 4、有网友插了两个手机,结果一个都检测不到,拔掉一个神奇的好了。   总之,主要是手机的问题,实在不行就换个手机试试,不要在一个手机上吊死。 5、如果手机型号识别了,但是没有识别WebView。 可能是要调试的APP没有打开WebView的调试模式 。会出现有的App能Inspect,有的不能。 可参考 Cordova/Ionic开发的Android APP启用Chrome Inspect调试的方法 如果点击Inspect后。出现空白页面的话,查看 此处解决方法 。 来源: oschina 链接: https://my.oschina.net/u/4381003/blog/4029664

Android AudioRecord vs. MediaRecorder for recording audio

时光总嘲笑我的痴心妄想 提交于 2021-02-17 07:32:16
问题 I want to record human voice on my Android phone. I noticed that Android has two classes to do this: AudioRecord and MediaRecorder. Can someone tell me what's the difference between the two and what are appropriate use cases for each? I want to be able to analyse human speech in real-time to measure amplitude, etc. Am I correct in understanding that AudioRecord is better suited for this task? I noticed on the official Android guide webpage for recording audio, they use MediaRecorder with no

cannot resolve symbol setOnClickListener in android

我怕爱的太早我们不能终老 提交于 2021-02-17 07:21:39
问题 When i run this program, it repeatedly saying that "cannot resolve symbol setOnClickListener".anyone please help me to solve this problem. import android.support.v7.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle

What is the differences between onAttach() and isAdded() in android Fragment?

好久不见. 提交于 2021-02-17 07:16:11
问题 Can anyone tell me what are the different of use of onAttach() and isAdded in Android Fragment? When create a new fragment onAttach() method creating default. I checked this question, the question is asked about !onDetech() and isAdded() , also one answer there, but I am not clear with that.. Thanks 回答1: This could be answered simply reading javadocs: /** * Called when a fragment is first attached to its context. * {@link #onCreate(Bundle)} will be called after this. */ public void onAttach

What is the differences between onAttach() and isAdded() in android Fragment?

♀尐吖头ヾ 提交于 2021-02-17 07:16:09
问题 Can anyone tell me what are the different of use of onAttach() and isAdded in Android Fragment? When create a new fragment onAttach() method creating default. I checked this question, the question is asked about !onDetech() and isAdded() , also one answer there, but I am not clear with that.. Thanks 回答1: This could be answered simply reading javadocs: /** * Called when a fragment is first attached to its context. * {@link #onCreate(Bundle)} will be called after this. */ public void onAttach