kotlin

Android Bundle usage

匆匆过客 提交于 2021-02-11 14:57:31
问题 Is it possible to use Android Bundle to create and putString() in Activity then getString() in Service on button click? If not what can i do? Example MainActivity.kt val bundle = Bundle() bundle.putString("MyString", "Message") val mesg = Message.obtain(null, MyService.SEND_MESSAGE_FLAG) mesg.obj = bundle try { myService!!.send(mesg) } catch (e: RemoteException) { } Service override fun handleMessage(msg: Message) { when (msg.what) { SEND_MESSAGE_FLAG -> { val data = msg.data val dataString =

Proguard removes com.sun.mail.imap.IMAPProvider

陌路散爱 提交于 2021-02-11 14:49:14
问题 In my app I send emails to some specific address, it all works fine, but when it comes to obfuscation, shrinking, etc with ProGuard it fails I've tried adding some ProGuard rules, which didn't work That's my ProGuard -keepclassmembernames class com.sun.mail.imap 2019-08-08 14:29:26.811 11724-12675/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5 Process: com.redegrow.besttaxi, PID: 11724 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3

Firebase realtime database: How to listen to a specific subset of items of a node?

十年热恋 提交于 2021-02-11 14:43:00
问题 I have the following structure within my firebase realtime database: artists ArtistID name listOfPaintings PaintingID1 PaintingID2 paintings (there can be PaintingID1 copies price PaintingID2 copies price ... PaintingIDX copies price Now I want to listen for changes of specific paintingIDs and specific ArtistIDs. For example I want to listen to PaintingID1, PaintingID6, PaintingID7, PaintingID11. My repository code so far: override fun observeThisPainting(painting: Painting,

Fixed number of tabs per page in TabLayout

房东的猫 提交于 2021-02-11 14:31:00
问题 I am using scrollable TabLayout with a ViewPager. I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3. I can't find a property to control the number of tabs displayed. 回答1: Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget

Fixed number of tabs per page in TabLayout

亡梦爱人 提交于 2021-02-11 14:29:35
问题 I am using scrollable TabLayout with a ViewPager. I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3. I can't find a property to control the number of tabs displayed. 回答1: Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget

Android Q ConnectivityManager.requestNetwork with timeout shows error Dialog that stops any subsequent requests

可紊 提交于 2021-02-11 14:19:27
问题 I'm using Android's ConnectivityManager.networkRequest(..) with a timeout to get a hold of a specific network after a queue from user input. Everything works fine most of the time, but if I let the request timeout, I notice I get another Dialog saying Something came up. The application has cancelled the request to choose a device." which requires the user to manually dismiss it before we can do any other network requests. My questions is: How can I dismiss this dialog programmatically? I do

Kotin lateinit Var Not initialized - Android Studio

跟風遠走 提交于 2021-02-11 14:02:31
问题 I am working on a simple contact app that stores the contact's name, email, and number. Language: Kotlin Architecture: MVVM But I am getting an error: lateinit property addContactViewModel has not been initialized Activity: class AddContact : AppCompatActivity() { private lateinit var addContactViewModel : AddContactViewModel companion object{ const val EXTRA_REPLY = "com.room.contacts.REPLY" } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding

Parcelable Model reinstatiates, MVVM Room LiveData

落花浮王杯 提交于 2021-02-11 14:01:17
问题 Here is my problem, I am using mvvm to load profile data from Dao, which was earlier updated when user logs in. Or if a new user an empty model loads. see my BasicProfileFragment and ViewModel. I am using LiveData to update fragment from Dao initially. Next, I want to edit/update the fields in different ways. keyboard input and updating data by Navigating to other fragments. Where data loaded as list from server. For eg. clicking the Gender strip and Navigate to Gender Fragment, Data

Not getting correct value of Storage Volume(Internal)

不羁的心 提交于 2021-02-11 13:41:30
问题 I want total internal space available in Phone but in this code getInternalFreeSpace returns correct value but getInternalStorageSpace doesn't return exact available space because of not counting ANDROID OS Size. Like my phone has 64GB but this code returns 51.6GB. The Only missing is 12.40 GB i.e. ANDROID OS size, 51.6GB + 12.40 = 64.00 fun getInternalStorageSpace(): Float{ val statsFs = StatFs(Environment.getDataDirectory().absolutePath) val sizeKB = statsFs.blockCountLong.toFloat() *

Upload multiple images(nearly 100) from Android to Amazon S3?

吃可爱长大的小学妹 提交于 2021-02-11 13:36:28
问题 I am trying to upload multiple image to amazon s3 bucket. The size of the images which i am trying to upload is nearly 300KB each. I am using loop to upload the images. But it's taking more time compared to ios. I am using the below code to upload the images to S3. val uploadObserver = transferUtility!!.upload(bucketname, , "img_$timeStamp.jpg", File(fileUri.path!!), md, CannedAccessControlList.PublicRead) uploadObserver.setTransferListener(object : TransferListener { override fun