Android Question Java online Share Facebook / Twitter / Gmail / etc..

Discussion in 'Android Questions' started by MarcoRome, Feb 19, 2015.

  1. MarcoRome

    MarcoRome Expert Licensed User

    Hi all, i found this interesting code:

    // code of share(String nameApp,String imagePath,String message) function
    public void share(String nameApp, String imagePath, String message) {
    try {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    List<ResolveInfo> resInfo = getPackageManager()
    if (!resInfo.isEmpty()) {
    for (ResolveInfo info : resInfo) {
    Intent targetedShare = new Intent(
    "image/jpeg"); // put here your mime
    if (info.activityInfo.packageName.toLowerCase().contains(
                                    nameApp)) {
    "Sample Photo");
    Intent.EXTRA_TEXT, message);
    Uri.fromFile(new File(imagePath)));
                Intent chooserIntent = Intent.createChooser(
                        targetedShareIntents.remove(0), "Select app to share");
                        targetedShareIntents.toArray(new Parcelable[] {}));
        } catch (Exception e) {
                    "Exception while sending image on" + nameApp + " "
                            + e.getMessage());
    For attaching image on gmail,facebook,twitter with text use below code.
    File filePath = new File("your image path");
    share("gmail",filePath.toString(),"your comment");
    share("facebook",filePath.toString(),"your comment");
    share("twitter",filePath.toString(),"your comment");

    But when i compile i have error about List<Intent>...

    Any idea ?
    ilan likes this.
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    You dont need to copy Java code for this.
  3. MarcoRome

    MarcoRome Expert Licensed User

    Hi thedesoltesoul...
    the question is share Facebook.
    I have this code that work without problem Whatsapp, Twitter, etc. but dont work with facebook.

    Dim i As Intent , uri, testo As String
    uri="********************" & CRLF &"Condiviso con:" & CRLF & ""
                testo = 
    "Inseriamo un testo corto da pochi caratteri..."
    "android.intent.extra.SUBJECT"Activity.Title  )      
    "android.intent.extra.TEXT", testo &  CRLF & uri)
    I try also AhaShare but i see that want Facebookid and RedirectUri ( i reading tutorial NJDude but now Fb want https as RedirectUrl)

    The question is... exist one intent or similar code that can i use for share in FB ??

    Thank you
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    This is very similar code to the java one (only one is for text and the other is for image). Is there an option to share with facebook popping up?
    lemonisdead and NJDude like this.
  5. MarcoRome

    MarcoRome Expert Licensed User

    Yes i see this that more or less is same thing. These filters are applications that you would like to use. Example: I want to share only with Gmail +, FB, WhatsApp, Twitter.
    Do you know exist code to share in FB without use AhaShare ( it's a fantastic library ) ??
  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