For our final recipe of this chapter, we're going to use Android Intents to share an image to the native Twitter app.
Firstly, you'll need to make sure you have the Twitter application installed on your Android simulator or device. Once you have the Twitter app installed, launch it and log in so that you can see your feed.
Next, find the postToTwitter
function in the app.js
file and replace it with the following:
try { var intent = Ti.Android.createIntent({ action : Ti.Android.ACTION_SEND, packageName : "com.twitter.android" }); intent.setType('image/*'); intent.putExtraUri(Ti.Android.EXTRA_STREAM, imageThumbnail.image.nativePath); intent.putExtra(Ti.Android.EXTRA_TEXT, txtTitle.value || 'Type your message here'); var shareActivity = Ti.Android.createIntentChooser(intent, "Share with"); Ti.Android.currentActivity.startActivity(shareActivity); } catch (e) { alert("Make sure you have Twitter installed...