android-studio

Use Gradle function from other gradle file

こ雲淡風輕ζ 提交于 2021-02-20 19:23:31
问题 I want to split my 300 lines build.gradle logically into multiple build files to make it easier to maintain and extend. As I've noticed, it is possible to split gradle tasks into multiple files and use them with: apply from: "myGradleFile" With this approach I sadly have no access to functions , defined in the second build script. Is it also possible to split Gradle functions into multiple files? Example: Let's say I have my default build.gradle with a Task which uses a function task

Kotlin delegate property causes a preview rendering error in Android Studio

半世苍凉 提交于 2021-02-20 19:08:01
问题 I have created a custom property dedicated to holding properties of the view that require invalidate() call for one of my projects: class InvalidatingProperty<T>(private var _value: T) { operator fun getValue(thisRef: View, property: KProperty<*>): T { return _value } operator fun setValue(thisRef: View, property: KProperty<*>, value: T) { _value = value thisRef.invalidate() } } In another project, I wanted to reuse some of my previous work, so i copied the views and their dependencies,

Kotlin delegate property causes a preview rendering error in Android Studio

旧时模样 提交于 2021-02-20 19:07:59
问题 I have created a custom property dedicated to holding properties of the view that require invalidate() call for one of my projects: class InvalidatingProperty<T>(private var _value: T) { operator fun getValue(thisRef: View, property: KProperty<*>): T { return _value } operator fun setValue(thisRef: View, property: KProperty<*>, value: T) { _value = value thisRef.invalidate() } } In another project, I wanted to reuse some of my previous work, so i copied the views and their dependencies,

How do i download files to the local downloads folder?

江枫思渺然 提交于 2021-02-20 04:55:07
问题 I enabled the download settings for files with WebView. I'm saving files with DownloadManager. But the files do not appear in the local downloads directory. The files I've downloaded are save here. > file/storage/emulated/0/Android/data/com.myapp/files/x.mp3 I've tried a lot. But somehow it was not downloaded in the local downloads folder. What should I do? My Code String string = String.valueOf((URLUtil.guessFileName(url, contentDisposition, mimeType))); DownloadManager.Request request = new

adb: CreateFileW 'null' failed: The system cannot find the specified file

牧云@^-^@ 提交于 2021-02-19 08:45:19
问题 I installed Android Studio 3.0.1 in Windows 10 and it turns out that I can not launch any emulator, as much as you create these emulators, these are not displayed and I get the following error: I have verified that the ADB is not running and that other processes also listen to port 5037 as other users indicate. The strange thing isadb: CreateFileW 'nul' failed: 回答1: This problem also appeared on my computer, but after reinstalling the Windows system and Android Studio, the problem is no

How to get EditText value to textview at the time of typing without button click in android [closed]

穿精又带淫゛_ 提交于 2021-02-19 07:48:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . Improve this question How to read data from EditText to textview at user input without button click 回答1: Try using textwatcher on Edittext and update textview using available methods. TextWatcher textWatcher = new TextWatcher() { @Override public void beforeTextChanged

In Android Studio, why do I have to click 'run app' twice in the emulator to start the app?

跟風遠走 提交于 2021-02-19 06:34:06
问题 In Android Studio, when I press play button to install and run the app on the Android Emulator, after about 5-10 seconds, I get a message on the bottom of the screen saying "Install successful" but the app doesn't actually run on the emulator, I have to press the play button again. This is quite frustrating because I have worked on projects where I just press play once and it installs and runs at the same time. I tried searching this forum but couldn't find an answer. Does anybody else

XML attributes arrangement in Android Studio

无人久伴 提交于 2021-02-19 05:49:05
问题 I like to arrange my XML files similar to this question But I'd like to add an ordering like this: View id Style Layout width and layout heigt Other layout_ attributes, sorted alphabetically Remaining attributes, sorted alphabetically Example: <Button android:id="@id/button_accept" style="@style/ButtonStyle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentStart="true" android:padding="16dp" android:text

'ACTION_MEDIA_SCANNER_SCAN_FILE:String' is deprecated

左心房为你撑大大i 提交于 2021-02-19 00:44:26
问题 activity?.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.fromFile(copyFile))) I got the warning "ACTION_MEDIA_SCANNER_SCAN_FILE is deprecated." in above code Is there a simple replacement code? Thank you 回答1: ACTION_MEDIA_SCANNER_SCAN_FILE Deprecated! You can use the following Java File file = new File(filePath); MediaScannerConnection.scanFile(context, new String[]{file.toString()}, null, null); Kotlin val file = File(filePath) MediaScannerConnection.scanFile(context, arrayOf

Cannot access 'androidx.activity.result.ActivityResultCaller'

一曲冷凌霜 提交于 2021-02-18 22:39:49
问题 I'm using androidx for quite a while and my Android project compiles fine, however recently my Android Studio throws tons of red for all Activity classes because of cannot access 'androidx.activity.result.ActivityResultCaller' which is a supertype of ... I use AppCompatActivity from androidx.appcompat:appcompat:1.1.0 My build.gradle has: ext.kotlin_version = '1.3.71' ... dependencies { classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.google.gms:google-services:4.3.3' And gradle