如何将照片库中的照片分享给我的应用程序?
问题描述:
我有一个用Titanium编写的应用程序。 在Android设备上的照片库中,单击通过共享。图片可以通过Gmail,消息,Goolge +,...分享... 我想添加一个图片可以通过我的应用程序共享的选项。 这个过程是否有解决方案?如何将照片库中的照片分享给我的应用程序?
谢谢。
答
你需要添加一个意图过滤器拦截正确Intant.ACTION_SEND
如图所示here:
<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();
现在,它的图标时,按“通过分享”在照片库中。但是当打开应用程序时,我无法抓住意图获取图像。 – batanlp 2013-05-06 10:25:21