receive_sharing_intent icon indicating copy to clipboard operation
receive_sharing_intent copied to clipboard

[Andoid] Not receiving XML and TXT files via "send to" action on android

Open np2048 opened this issue 3 years ago • 4 comments

The bug is reproducible in the example application.

What doesn't work: When I try to send a TXT or XML file, from an application to the example app, it doesn't receive the file into the "Shared files" list. The value list looks empty when I catch it in the debugger.

What does work just fine: When I try to send a PDF file everything is OK, it's path appears in the top list of the example application. Also if I select a PDF file and a TXT or XML file they come together as a list in the demo application correctly indicating the Type of both files as "FILE". It all works correctly with images or video files too, but not with the text files.

If I select the option "open with..." into the sender app then the content of a file gets to the receiving application correctly (it appears in the second part of the example app: "Shared urls/text"). But it doesn't work if I try to send it as a single file.

np2048 avatar Apr 28 '21 18:04 np2048

I have the same problem, have you found a solution?

Ricky1968 avatar May 23 '21 21:05 Ricky1968

I think the same issue is reported here as well:

https://github.com/KasemJaffer/receive_sharing_intent/issues/139

ntmcminn avatar May 25 '21 02:05 ntmcminn

Any update on this issue?

lightning331 avatar Aug 25 '21 15:08 lightning331

Les traigo la solucion: MODIFIQUEN: C:\flutter.pub-cache\hosted\pub.dartlang.org\receive_sharing_intent-1.4.5\android\src\main\kotlin\com\kasem\receive_sharing_intent\ReceiveSharingIntentPlugin.kt

private fun handleIntent(intent: Intent, initial: Boolean) {
    
    if(intent.action == Intent.ACTION_VIEW){
            val value = getMediaUris(intent)
            if (initial) initialMedia = value
            latestMedia = value
            eventSinkMedia?.success(latestMedia?.toString())
            return 
    }else if((intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_SEND_MULTIPLE)&&intent.getStringExtra(Intent.EXTRA_TEXT)==null){
            val value = getMediaUris(intent)
            if (initial) initialMedia = value
            latestMedia = value
            eventSinkMedia?.success(latestMedia?.toString())
    }else{
            val value = intent.getStringExtra(Intent.EXTRA_TEXT)
            if (initial) initialText = value
            latestText = value
            eventSinkText?.success(latestText)
    }
}



private fun getMediaUris(intent: Intent?): JSONArray? {

/* AGREGANDO */ Intent.ACTION_VIEW -> { var uri = intent.getData(); val path = uri?.let{ FileDirectory.getAbsolutePath(applicationContext, it) } //val path = FileDirectory.getAbsolutePath(applicationContext, it) if (path != null) { val type = getMediaType(path) val thumbnail = getThumbnail(path, type) val duration = getDuration(path, type) JSONArray().put( JSONObject() .put("path", path) .put("type", type.ordinal) .put("thumbnail", thumbnail) .put("duration", duration) ) } else null }

Bueno les comparto mi solucion

yaircaballero10 avatar Feb 26 '22 20:02 yaircaballero10