1

I have an application written in Titanium. And on Android device, in Photo gallery, click share via. Picture can share via Gmail, Message, Goolge+, ... I want add one more option that picture can share via my application. Is there have any solution for this process?

Thanks.

4

1 回答 1

0

您需要添加一个意图过滤器来拦截正确的Intant.ACTION_SEND如下所示:

 <intent-filter>
     <action android:name="android.intent.action.SEND" />
     <category android:name="android.intent.category.DEFAULT" />
     <data android:mimeType="image/*" />
 </intent-filter>

 var win = Ti.UI.createWindow({
     backgroundColor: '#fff',
     fullscreen: false,
     exitOnClose: true
 });
 win.addEventListener('open', function(e) {
     var intent = Ti.Android.currentActivity.getIntent();
     var iname = Ti.Android.EXTRA_STREAM;
     if (intent && intent.hasExtra(iname)) {
         // Create ImageView from TiBlob
         var blob = intent.getBlobExtra(iname);
         win.add(Ti.UI.createImageView({
             image: blob,
             height: 300,
             width: 300,
             left: 0,
             top: 0
         }));
     } else {
         Ti.API.info('No extra named "' + iname + '" found in Intent');
     }
 });        
 win.open();
于 2013-05-06T07:03:13.957 回答