0

In my previous question, i asked "how to download Facebook profile picture" and i got answer that "Use an AsyncTask to download it and save it to your app's disk space".

i am using sencha touch (its all about java script and html) for creating views with phonegap. i need to download image from web (from this url https://graph.facebook.com/username/picture).

so, when i was learning AsyncTask, i had a doubt that "can i use AsyncTask in sencha android application?", because i didn't create views (i mean button, panel, etc..) using activity xml.

is there any other solution to download picture from web in sencha touch application (Android) ?

Update for the solution

i used below facebook api to get the profile picture url and Phonegap file Api for downloading picture as @Lukas K said.

 FB.api('/'+fbusername+'/picture?redirect=false', function(response) {
      localStorage.fbpicurl = response.data.url;
     });
Community
  • 1
  • 1
Viswa
  • 3,211
  • 5
  • 34
  • 65

2 Answers2

1

You can use sencha's delayed task like this:

        var task = Ext.create(
                'Ext.util.DelayedTask',
                function() {
                    Ext.getCmp("imageId").setSrc( 'https://graph.facebook.com/username/picture' );
                }
            );
        task.delay(100);

This will start downloading the image after 100ms. I hope this is what you wanted to do, If not then do whatever as delayed task in the function.

ThinkFloyd
  • 4,981
  • 6
  • 36
  • 56
  • Thanks @ThinkFloyd, but i want to download(and save it in database) profile picture, not just display. – Viswa Jan 22 '13 at 04:58
1

You can convert it into base64 and store it in the localStorage. But the space of the LocalStorage is limited to 5MB. After reaching the Limit the device will prompt the user to give more space.

Do you use phonegap in addition to Sencha Touch? Phonegap provides access to the phone's file system, where you can store your pictures.

Phonegap File Api: http://docs.phonegap.com/en/2.3.0/cordova_file_file.md.html#File

Lukas K.
  • 863
  • 5
  • 15