Android Question Share contact via share menu

fanfalveto

Active Member
Licensed User
Longtime User
Looking at the forums I managed to share photos, files, images from the camera, etc .. from the menu to share (thanks to all), but I can not share a contact directly from the agenda.
This is the error that gives me some idea?
Thank you very much.
this is what i see from:"ExtraStr:"&Intent1.ExtrasToString)
B4X:
ExtraStr:Bundle[{vcard=vcard, android.intent.extra.STREAM=content://com.android.contacts/contacts/as_multi_vcard/1897i75def7ce88368584%3A}]
and this is the error:
B4X:
mensaje_getpathfromcontentresultc (java line: 735)
java.lang.IllegalStateException: Unknown URL: content://media/external/contacts/
 

fanfalveto

Active Member
Licensed User
Longtime User
GetPathFromContentResultC, this works fine with files, but no with contacts via phone agenda
B4X:
Sub GetPathFromContentResultc(UriString As String) As String
    Log ("entra a getpath     "&UriString)
  If UriString.StartsWith("/") Then Return UriString 'If the user used a file manager to choose the image
  Dim Cursor1 As Cursor

  Dim Uri1 As Uri
  Dim Proj() As String = Array As String("_data")
  Dim cr As ContentResolver
  cr.Initialize("")
  If UriString.StartsWith("content://com.android.providers.media.documents") Then 'ficheros
  Dim i As Int = UriString.IndexOf("%3A")
  Dim id As String = UriString.SubString(i + 3)
  Uri1.Parse("content://media/external/images/media")
  Cursor1 = cr.Query(Uri1, Proj, "_id = ?", Array As String(id), "")
   

        Log("entra para ver contactos")
        Dim i As Int = UriString.IndexOf("%3A")
  Dim id As String = UriString.SubString(i + 3)
  Uri1.Parse("content://media/external/contacts/")
  Cursor1 = cr.Query(Uri1, Proj, "_id = ?", Array As String(id), "")
       
        Else
  Uri1.Parse(UriString)
   
  Cursor1 = cr.Query(Uri1, Proj, "", Null, "")
  End If
  Cursor1.Position = 0
  Dim res As String
  res = Cursor1.GetString("_data")
    Log("res    "&res)
  Cursor1.Close
  Return res
End Sub
Thanks.
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
I get that
B4X:
ExtraStr:Bundle[{vcard=vcard, android.intent.extra.STREAM=content://com.android.contacts/contacts/as_multi_vcard/1897i75def7ce88368584%3A}]
with
B4X:
  Dim Intent1 As Intent
    Intent1 = Activity.GetStartingIntent
    If Intent1.Action = "android.intent.action.SEND" Then
        Log("Invoked by Share Via - single image")
    Else If Intent1.Action = "android.intent.action.SEND_MULTIPLE" Then
        Log("Invoked by Share Via - multiple images")
    Else If Intent1.Action = "android.intent.action.MAIN" Then
        Log("Invoked by Click on App")
    Else
        Log("Invoked by unknown method")
    End If
    Log("Action  :"&Intent1.Action)
    Log("GetData :"&Intent1.GetData)

        Dim str As String
Intent1.ExtrasToString.Contains("com.android.contacts/contacts") Then
             str = Intent1.ExtrasToString
            contactos(str)
then
B4X:
Sub contactos(rutas As String)
rutas=rutas.SubString2(rutas.LastIndexOf("/")+1,rutas.Length-2)
    Log("rutas2      "&rutas)
con.Initialize
End Sub
I get
B4X:
rutas2      1897i75def7ce88368584%3A
I thought that was the id but not i try
B4X:
 Log(con.GetNameFromId(rutas))
Any idea how i get the phone number and name?
Thanks
 
Upvote 0

fanfalveto

Active Member
Licensed User
Longtime User
First sorry for my English is google and sometimes translation does not quite right.
I have an app that uses firebase to send messages and attachments (this does well), I would like from contacts to open the option to share can send the business card of the selected contact with the application.
The application can now share any file from ESexplorer for example.
I do not know if I could explain.
Thank you very much.
 
Upvote 0
Top