Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Save Webview in Android Photogallery

$
0
0

Hello, i need help with saving an image to the android photogallery. My Code so far:

webView = Titanium.UI.createWebView({
            top : 0,
            willHandleTouches : true,
            backgroundColor:'#ffffff',
            visible : true,
            tabBarHidden : true,
            scalesPageToFit : true,
            enableZoomControls : true,
            touchEnabled : true,
            width : '100%',
            height : '100%',
            url:fileurl, 
        });
        attachmentWin.add(webView);
 
        webView.addEventListener('longpress',function(e){
            saveDialog = aD.saveAttachment(lang);
            saveDialog.show();
            saveDialog.addEventListener('click',function(e){
                if(e.index == 0)
                {
                blobObj = webView.toImage();  
                    var f = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'img.png');
                    f.write(blobObj);
                    Titanium.Media.saveToPhotoGallery(f,{
                        success: function(e) {
                            Titanium.UI.createAlertDialog({
                                title:'There',
                                message:'you go '
                            }).show();      
                        },
                        error: function(e) {
                            Titanium.UI.createAlertDialog({
                                title:'Error saving',
                                message:e.error
                            }).show();
                        }
                    });     
                }
                if(e.index == 1)
                {
                    saveDialog.hide();
                }
            });
        });
If i press the Savebutton on my alertDialog (e.index == 0) there seems something to happen, but after a short moment it falls into the error and says: Error Saving: Could not decode bitmap from argument.

Can somebody help? Thanks!


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>