I am getting this issue, I tried using kotlin coroutines and Async still getting the same Calling this from Your main thread can lead to deadlock,

May 04, 2022, at 8:30 PM

I also made another class that implements runnable to make a new thread still it's now working, Also tried with Aynctask. At last, I made a view model but still same issue. Anyone, please Help. Here is what I am trying to do

GlobalScope.launch (Dispatchers.IO){
                    Toast.makeText(this@AddPost,"I have gone Mad",Toast.LENGTH_LONG).show()

fun createFile (filePath:String):String{
        var file:File=File(filePath)
        val gfile = com.google.api.services.drive.model.File()
        var mediaContent:FileContent= FileContent("application/pdf",file)
        try {
            var myFile= mDrive?.files()?.create(gfile,mediaContent)?.execute()
            var listOfPermission: MutableList<com.google.api.services.drive.model.Permission>? =myFile!!.permissions
                for (per in listOfPermission){
//                    Toast.makeText(this,per.toString(),Toast.LENGTH_LONG).show()
//            Toast.makeText(this,"Uploaded Files",Toast.LENGTH_SHORT).show()
            return  myFile!!.id
        catch (e:Exception){
//            Toast.makeText(this,"Some Error Occured in Uploading Files"+e.toString(),Toast.LENGTH_SHORT).show()
        return "Failed"

I am running this function on a button click in an activity tried all the methods from coroutines to Aync and making new thread still getting the same issue.

Answer 1

Don't use GlobalScope, instead use lifeCycleScope. This might resolve the issue.

Rent Charter Buses Company
Android Manifest permissions issue

Android Manifest permissions issue

I have an app where im using uses-permission tags in the AndroidManifestxml to give some permissions to my app, eg CAMERA

how to play .mpd file?

how to play .mpd file?

I have ampd dash of one of my

Can not use Vulkan Subgroup operations in Android Studio

Can not use Vulkan Subgroup operations in Android Studio

I'm writing a Vulkan compute shader in Android studio and launching it on Android phoneThe problem I'm experiencing is next - I can not use any subgroup operations like subgroupAdd and subgroupElect

Jetpack compose and AppCompat dark mode

Jetpack compose and AppCompat dark mode

In order to toggle dark/light mode in AppCompatActivity we use getDelegate()setLocalNightMode, but since in jetpack compose we extend ComponentActivity instead of AppCompatActivity