android-studio

Run a single .kt file in Android Studio

…衆ロ難τιáo~ 提交于 2021-01-27 07:22:13
问题 I created a Scratch Kotlin file in Android Studio. I simply want to run this scratch.kt file and get output. I fiddled with Run Cofigurations but cannot understand what will go into Main Class. 回答1: If you create a top-level function called main in any kotlin file, a green run button will appear next to it that allows you to run it as a program: Note that this works in Android Studio as well as in IntelliJ IDEA. 回答2: You can create a scratch kotlin file with File -> New -> Scratch File ->

Show notifications on Screen in Android

核能气质少年 提交于 2021-01-27 05:56:27
问题 i am using this code for sending local notifications mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)) .setContentTitle(title) .setDefaults(Notification

Android - ellipsize=“end” Not Showing Three Dots

怎甘沉沦 提交于 2021-01-27 05:44:33
问题 I'm working on a TextView which is contained in a ConstraintLayout . I want ellipsize to add three dots at the end of text(in the TextView) if its length exceeds maxLength. maxLines="1" and ellipsize="end" seemed to the best answer after a thorough research about my question. Unfortunately, it didn't work for my case. The three dots did't show at all. Here's the snapshot : The original string was "Test for long description"(The n was dropped). It's supposed to show "Test for long descrip...".

Android - ellipsize=“end” Not Showing Three Dots

蓝咒 提交于 2021-01-27 05:44:17
问题 I'm working on a TextView which is contained in a ConstraintLayout . I want ellipsize to add three dots at the end of text(in the TextView) if its length exceeds maxLength. maxLines="1" and ellipsize="end" seemed to the best answer after a thorough research about my question. Unfortunately, it didn't work for my case. The three dots did't show at all. Here's the snapshot : The original string was "Test for long description"(The n was dropped). It's supposed to show "Test for long descrip...".

How to fix initialization error for DefaultKotlinSourceSetKt?

谁都会走 提交于 2021-01-27 05:36:28
问题 With project build (or simple Gradle sync), I have the following error: Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKt This error shows after change gradle wrapper version from 4.10 to 6.2.2 (because min gradle wrapper version required 5.6.4, but with 5.6.4 Apollo has error "Access denied" for build folder) Sorry for mistakes, my English is very bad( My build.gradle: apply plugin: 'com.android

How do I see database tables in Android Studio 3.1

橙三吉。 提交于 2021-01-27 05:20:57
问题 I have recently updated Android Studio to version 3.1. Afterward, I couldn't find how to view my database tables. 回答1: You can use Device File Explorer: View -> Tool Windows -> Device File Explorer And find with its help your db among packages. E.g. data -> data -> com.your.app -> databases Save it locally and open with any external tool like the SQLite Browser. 回答2: After Android Studio 4.1 version, we can use Database Inspector 来源: https://stackoverflow.com/questions/49595717/how-do-i-see

ConstraintLayout Barrier not visible in design view

你离开我真会死。 提交于 2021-01-27 04:52:07
问题 I'm trying to add a barrier to my ConstraintLayout in Android Studio but it is not showing up the way it should in design view. I have been following this tutorial, but I can't get things to work properly. I'm currently using: Android Studio 3.1.1 androidx.constraintlayout:constraintlayout:1.1.3 Things I have tried: Invalidate caches/restart Removing the attribute tools:layout_editor_absoluteX Fiddling around! Here's my test.xml : <?xml version="1.0" encoding="utf-8"?> <androidx

Android Studio API Level warning not showing

允我心安 提交于 2021-01-27 04:45:15
问题 I'm having trouble, there is no warning when I use methods above API Level 8 setCalendarViewShown(false); Is just an example Even if I build my app there's no error, I'll only encounter the error when the app reaches the unsupported method. 回答1: I just solve my problem I just check the File > Settings > Inspections > Android Lint > "Calling new methods on older versions" because it's unchecked before 来源: https://stackoverflow.com/questions/24566221/android-studio-api-level-warning-not-showing

Global object declaration in kotlin

夙愿已清 提交于 2021-01-27 04:39:11
问题 How to declare objects globally in kotlin like in java TextView tv; . Or any method to call the same variable in different methods/functions. override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val textView: TextView = findViewById(R.id.texfirst) as TextView textView.setOnClickListener { Toast.makeText(applicationContext,"Welcome to Kotlin ! $abc "+textView.text, Toast.LENGTH_LONG).show() } myFunction(textView) } fun

The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0

北城以北 提交于 2021-01-27 03:51:13
问题 I would like to add notification with firebase on my app. I followed a video on YouTube (https://www.youtube.com/watch?v=xx7hemn3FY4) But I have an error when I do the same thing in my flutter project : The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 11.8.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. I tried several things as you can see in comment. Project