I'm working with Titanium SDK 2.1.3 and developing for both iOS and Android. Our application can open files (at the moment txt and images on Android), in iOS we use a special library that handles the files while in Android we want to open the files using Android's intents. But this causes an exception with images on Android, saying got exception decoding bitmap
. Here's my code that makes the Intent:
var appFile = Ti.Filesystem.getFile(fileNativePath);
if(appFile)
{
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
type : appFile.read().mimeType,
data : appFile.nativePath
});
try {
Ti.Android.currentActivity.startActivity(intent);
}
catch(e)
{
Ti.API.error(e);
alert('No apps for this');
}
}
The native path for the image I'm trying to open is the following:
file:///data/data/nenvo.com.desktop/app_appdata/1372368987874.jpg
The full Exception is the following:
[ERROR][UriImage( 2887)] got exception decoding bitmap
[ERROR][UriImage( 2887)] java.lang.NullPointerException
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeInputStream(Util.java:336)
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeBitmap(Util.java:307)
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeBitmap(Util.java:299)
[ERROR][UriImage( 2887)] at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:94)
[ERROR][UriImage( 2887)] at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:86)
[ERROR][UriImage( 2887)] at com.android.camera.gallery.UriImage.thumbBitmap(UriImage.java:120)
[ERROR][UriImage( 2887)] at com.android.camera.ImageGetter$ImageGetterRunnable.executeRequest(ImageGetter.java:173)
[ERROR][UriImage( 2887)] at com.android.camera.ImageGetter$ImageGetterRunnable.run(ImageGetter.java:149)
[ERROR][UriImage( 2887)] at java.lang.Thread.run(Thread.java:856)
[WARN][NetworkManagementSocketTagger( 76)] setKernelCountSet(10044, 0) failed with errno -2
[ERROR][UriImage( 2887)] got exception decoding bitmap
[ERROR][UriImage( 2887)] java.lang.NullPointerException
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeInputStream(Util.java:336)
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeBitmap(Util.java:307)
[ERROR][UriImage( 2887)] at com.android.camera.Util.makeBitmap(Util.java:299)
[ERROR][UriImage( 2887)] at com.android.camera.gallery.UriImage.fullSizeBitmap(UriImage.java:94)
[ERROR][UriImage( 2887)] at com.android.camera.ImageGetter$ImageGetterRunnable.executeRequest(ImageGetter.java:204)
[ERROR][UriImage( 2887)] at com.android.camera.ImageGetter$ImageGetterRunnable.run(ImageGetter.java:149)
[ERROR][UriImage( 2887)] at java.lang.Thread.run(Thread.java:856)
What's wrong with my approach? Thanks for any help in advance.