android

Create Custom class for TextInputLayout

孤街浪徒 提交于 2021-02-18 11:31:12
问题 In TextInputLayout I want to add TextInputEditText via Custom class Here is the code for custom class I have created : public class CustomTextInputEditText extends TextInputLayout { private TextInputEditText editText; public CustomTextInputEditText(@NonNull Context context) { this(context, null); } public CustomTextInputEditText(@NonNull Context context, @Nullable AttributeSet attrs) { this(context, attrs, R.style.Widget_MaterialComponents_TextInputLayout_OutlinedBox); } public

singleTask launchMode in android not working

烈酒焚心 提交于 2021-02-18 11:27:31
问题 So, I have 4 activities Activity Activity1 , Activity2 , Activity3 and Activity4 . I start from Activity1 then on some event I start Activity2 then on some event on Activity2 I start Activity3 as a new task as public void onClick(View v) { Intent intent = new Intent(Activity2.this, Activity3.class); intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK|Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } Here Activity2 launchMode is decalared as singleTask. Then I navigate from Activity3 to

Gradle dependencies for different api levels

吃可爱长大的小学妹 提交于 2021-02-18 11:26:08
问题 unfortunately I have to support Android 2.3, but I want to use a third party ui widget that has min-sdk 14 (Android 4.0). Is there a way to include the dependency with min-sdk 14? In code I would check Build.SDK_INT to determine whether to use the ui widget with min SDK 14 or a fallback UI widget. 回答1: It is not possible... If you have a dependency it is inside you compilation. inside your apk. You can choose if you want to use this third party lib with if(SDK_INT) but the lib will be

Gradle dependencies for different api levels

允我心安 提交于 2021-02-18 11:25:26
问题 unfortunately I have to support Android 2.3, but I want to use a third party ui widget that has min-sdk 14 (Android 4.0). Is there a way to include the dependency with min-sdk 14? In code I would check Build.SDK_INT to determine whether to use the ui widget with min SDK 14 or a fallback UI widget. 回答1: It is not possible... If you have a dependency it is inside you compilation. inside your apk. You can choose if you want to use this third party lib with if(SDK_INT) but the lib will be

Encrypt video on the fly from android camera

百般思念 提交于 2021-02-18 11:14:26
问题 I want to encrypt video on the fly that android camera captures. So I need to tell android MediaRecorder to write it video stream to my CipherOutputStream . The problem is MediaRecorder.setOutputFile() method accepts only FileDescriptor and there is no way to get encrypting file descriptor from CipherOutputStream. So my question is how can I either emulate FileDescriptor to receive data writes and do encryption manually or somehow convince MediaRecorder to stream video into CipherOutputStream

Android open browser from service avoiding multiple tabs

懵懂的女人 提交于 2021-02-18 11:03:25
问题 I am trying to open the browser window from my service with a link that opens in the current tab of the browser. when I use Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com")); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); context.startActivity(intent); If the browser was opened and in the foreground before my service starts the intent and the browser opens the link in the same window/tab. If the Browser was minimized and the

Is MD5 guaranteed to be available for use with MessageDigest in Android?

谁说我不能喝 提交于 2021-02-18 10:59:45
问题 I want to know if the MD5 digest algorithm is guaranteed to be available in all Android devices before I bluntly ignore the checked exception that MessageDigest.getInstance("MD5") can throw. 回答1: The Android JCE (Java Cryptography Extension) is based off the bouncycastle implementation but stripped down. bouncycastle provides a ton of different MessageDigests which can be found here. There's no guarantee that every Android device supports MD5 but it's extremely common and is likely to be on

Android Studio 3.0 unknown element <library> found

佐手、 提交于 2021-02-18 10:58:20
问题 After I updated Android Studio, one of my projects cannot be built. The error message is: Error:(20) error: unknown element <library> found. Error:(20) unknown element <library> found. Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details Error:com.android.tools

notify once the audio is finished playing

有些话、适合烂在心里 提交于 2021-02-18 10:56:25
问题 Well i am trying to implement basic functionality of voice recording , like Record , play/pause , stop i am able to do all of them but the only issue is how can i get notified once the audio gets finished playing. I mean if i play an audio file then once it gets finished playing i want a notification that it is stopped now. so far i have used mPlayer.start() // to start the audio mPlayer.stop(); // to stop the audio mPlayer.pause(); //to pause the audio i am just trying to find out how would

toArray with pre sized array

微笑、不失礼 提交于 2021-02-18 10:49:47
问题 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