O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sharing on Android using Intents

For our final recipe of this chapter, we're going to use Android Intents to share an image to the native Twitter app.

How to do it…

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required