Android Code Snippet Share text messages in all social (and not) apps

Discussion in 'Code Snippets' started by hatzisn, Nov 25, 2018.

  1. hatzisn

    hatzisn Active Member Licensed User

    Here is a code I developed with cooking and mixing of given recipies... Share text (you can include URIs) in every social app and more... Use it in activities. Have fun...

    Sub ShareMessage(sMes As String, app As String)
    Dim i As Intent
    Dim jo As JavaObject
    Dim sPackage As String
    Select Case app.ToLowerCase
    Case "facebook"
               sPackage = 
    Case "twitter"
               sPackage = 
    Case "viber"
               sPackage = 
    Case "messenger"
               sPackage = 
    Case "instagram"
               sPackage = 
    Case "whatsapp"
               sPackage = 
    Case "choose"
               sPackage = 
    End Select
       i = jo.RunMethod(
    "intnt"Array As String(sMes, sPackage))
    End Sub

    #If JAVA

    import android.content.Intent;

    public Intent intnt(String message, String applicationpackage){
       Intent i = new Intent(Intent.ACTION_SEND);
       i.putExtra(Intent.EXTRA_TEXT, message);
       if (applicationpackage=="choose"){
           return Intent.createChooser(i,"Share using");
           return i;

    #End If
    Last edited: Nov 25, 2018
    Alexander Stolte, yiankos1 and Almora like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice