android

Using custom attrs in styles.xml in android

我的未来我决定 提交于 2021-02-18 12:30:10
问题 I made a custom attribute style as <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="EffectsTextView"> <attr name="strokeWidth" format="float" /> <attr name="strokeMiter" format="float" /> <attr name="strokeColor" format="color" /> </declare-styleable> </resources> In Layout file, I could use this custom attribute assigning a namespace for this attribute: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:effects="http://schemas.android

Make ObjectAnimator animation duration independent of global animator duration scale setting in developer options

纵饮孤独 提交于 2021-02-18 12:29:17
问题 How can you make ObjectAnimator independent of the "Animator duration scale" developer options setting when constant and unmodifiable speed is critical? 回答1: I noticed there is no explicit answer for this. You can do this by calling the hidden API via reflection: // Get duration scale from the global settings. float durationScale = Settings.Global.getFloat(context.getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 0); // If global duration scale is not 1 (default), try to override

How to emulate Android's productFlavors in a pure java gradle module?

北城余情 提交于 2021-02-18 12:28:15
问题 I need three flavors: fake staging prod fake will provide classes like FakeUser , FakeUserDb - it's very important that these classes are not compiled into the prod flavor. prod and staging are completely identical, except that I need to compile a different String url into prod vs staging . So, I need to create an "abstract" real flavor that both prod and staging inherit. This can be easily done with the android gradle plugin, but how can I do it in a pure java gradle module? 回答1: For each

How to emulate Android's productFlavors in a pure java gradle module?

喜你入骨 提交于 2021-02-18 12:28:12
问题 I need three flavors: fake staging prod fake will provide classes like FakeUser , FakeUserDb - it's very important that these classes are not compiled into the prod flavor. prod and staging are completely identical, except that I need to compile a different String url into prod vs staging . So, I need to create an "abstract" real flavor that both prod and staging inherit. This can be easily done with the android gradle plugin, but how can I do it in a pure java gradle module? 回答1: For each

Convert parametized Enum to Enumerated Annotation in android

 ̄綄美尐妖づ 提交于 2021-02-18 12:27:20
问题 I have a question regarding to the andriod @IntDef Annotation. I know that in its basic usage, it should replace the enum . But what if I have a parameterized enum with multiple hardwired values for example public enum MyEnum { YES(true, 1), NO(false, 0); private boolean boolState; private boolean intState; MyEnum(boolean boolState, int intState) { this.boolState = boolState; this.intState = intState; } public boolean getBoolState() { return boolState; } public int getIntState() { return

Is there a way to start android emulator in Travis CI build?

♀尐吖头ヾ 提交于 2021-02-18 12:26:26
问题 I have python wrapper-library for adb where I have unit-test which depend on emulator or real device (since they execute adb commands). I want also to use Travis CI as build environment along with executing those unit tests for each build. Is there a way to have android emulator available somewhow in Travis CI, so that unit tests can execute adb commands? Thanks in advance! 回答1: According to the Travis CI documentation, you can start an emulator with the following script in your .travis.yml :

Showing Folder with Video File in RecyclerView

*爱你&永不变心* 提交于 2021-02-18 12:20:14
问题 I am listing all my media files in a recycler view. Suppose a media file is in a folder, then I want to show that folder in my recycler view too. Here is my code to list media files var projection = arrayOf(MediaStore.Video.Media.DISPLAY_NAME) var cursor = CursorLoader(applicationContext, MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null).loadInBackground() if (cursor != null) { while (cursor.moveToNext()) { val name = cursor.getString(cursor.getColumnIndex(MediaStore

Showing Folder with Video File in RecyclerView

房东的猫 提交于 2021-02-18 12:20:10
问题 I am listing all my media files in a recycler view. Suppose a media file is in a folder, then I want to show that folder in my recycler view too. Here is my code to list media files var projection = arrayOf(MediaStore.Video.Media.DISPLAY_NAME) var cursor = CursorLoader(applicationContext, MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection, null, null, null).loadInBackground() if (cursor != null) { while (cursor.moveToNext()) { val name = cursor.getString(cursor.getColumnIndex(MediaStore

Android Bluetooth StartDiscovery() always returns false

落爺英雄遲暮 提交于 2021-02-18 12:16:04
问题 I am trying to discover bluetooth devices nearby, but startDiscovery() always returns false, as if it is not working. Therefore it is not able to find devices. I saw that i have to include Coarse_Location permission apart from Bluetooth and Bluetooth_Admin, but anyway, it doesn´t work. Here is the code I am trying right now, where there are mainly traces to see how it works: public class BluetoothActivity extends AppCompatActivity { RecyclerView recyclerView; ArrayList<BluetoothDevice>

How to pass context?

寵の児 提交于 2021-02-18 12:15:07
问题 I want to pass the context of the main activity to another class in order to create a Toast. My main activity calls a class that will delete a file. The class that deletes files will call a toast if the file does not exist. Here is my code: public class MyActivity extends AppCompatActivity { public void onCreate(Bundle savedInstanceState) { // create a file Button buttoncreate = (Button)findViewById(R.id.create_button); Button buttondelete = (Button)findViewById(R.id.delete_button); ...