In my TiApp.xml i got the following block :
<activity android:name=".TestActivity" android:label="@string/app_name" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:label="@string/kmob.intent.menu.send">
<data android:mimeType="*/*"/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.SEND"/>
</intent-filter>
</activity>
And it's working great. I can go in the photo gallery, select a photo and i can share the photo with my application. But in my application i got a problem. I need to access to the filename or at least its extension. But i have only a blob with the content of the image.
if (OS_ANDROID) {
var intent = Ti.Android.currentActivity.getIntent();
if (intent && intent.action == 'android.intent.action.SEND') {
// Blob contains the content of the image (an application/octet-stream data). But there's no filename or filepath or file mimetype or whatever
var blob = intent.getBlobExtra(Ti.Android.EXTRA_STREAM);
// How can i access the native file or its filename ?
}
}
How can i access the native file or its filename ? Or at least its extension ? (that's the only thing i need since i have the file content. I can create a temporary file with the content by i need the extension)
In the documentation i can only find examples with simple text files or just displaying the image content. They never access to the native file or its filename.
Here the string representation of intent and blob :
intent = {
"action": "android.intent.action.SEND",
"bubbleParent": true,
"data": null,
"type": "image/jpeg", // NOTE : This value is not always the same. For an android 4.2.x, it's "image/jpeg", on android 4.1.x, it's "image/*".
"apiName": "Ti.Android.Intent",
"flags": 50331649
};
blob = {
"height": 0,
"bubbleParent": true,
"type": 2,
"mimeType": "application/octet-stream",
"apiName": "Ti.Blob",
"nativePath": null,
"file": null,
"text": "<IMAGE CONTENT AS STRING>"
}