Search code examples
androidfacebookandroid-intenttitaniumshare

Titanium.Android.Intent share on social media


I'm developing an App that shares news on "Only" native apps like Facebook, Twitter and LinkedIn.

I can't make intent shares custom to display only the apps I stated before. And using custom modules open apps in the browser.

I'm using titanium... So any help with this?

Thanks.


Solution

  • I am using the following intents to share on native Facebook and twitter apps:

    var intFB = Ti.Android.createIntent({
        action : Ti.Android.ACTION_SEND,
        packageName : "com.facebook.katana",                        
        type : "text/plain"
    });                    
    
    intFB.putExtra(Ti.Android.EXTRA_TEXT, yourLink);
    //facebook only supports LINKS(!!!)
    Ti.Android.currentActivity.startActivity(intFB);
    
    var intTwitter = Ti.Android.createIntent({
        action: Ti.Android.ACTION_SEND,
        packageName: "com.twitter.android",     
        flags: Ti.Android.FLAG_ACTIVITY_NEW_TASK,
        type: "text/plain"
    });
    
    intTwitter.putExtra( Ti.Android.EXTRA_TEXT, yourMessage); 
    //twitter supports any kind of string content (link, text, etc)
    Ti.Android.currentActivity.startActivity( intTwitter );