Large Applications

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Large Applications

Postby tttcowan » Tue Oct 19, 2010 12:08 pm

Hi,

I'm looking into creating a game with full speach and music, this is going to be a problem relating to space as it looks like it's got the potential to be in the 100Mb mark. I've seen games which download extra content on install but reports seem to be that this often fails or the files become corrupted... Has anyone looked into this before? So downloading and writing resource files directly to the sd card? Or is there a better way of getting round this issue?

It's a major stumbling block in general when comparing Android to the Iphone OS as the Iphone handles large applications without any issues. It's not a problem for the minute but it will be in the coming months so anyones thoughts would be great... It's certainly something that needs to be tackled by Google or the Android Community at some point.
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Re: Large Applications

Postby blundell » Tue Oct 19, 2010 12:56 pm

You could target 2.2 > then your app can be installed straight to SD.

or

Just implement downloading to the SD for your extra data, if it gets corrupt it's easy enough to inform the user that it's corrupt and to redownload. :-)
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Large Applications

Postby tttcowan » Tue Oct 19, 2010 2:02 pm

blundell wrote:You could target 2.2 > then your app can be installed straight to SD.

or

Just implement downloading to the SD for your extra data, if it gets corrupt it's easy enough to inform the user that it's corrupt and to redownload. :-)


Thanks for getting back to me, the problem with your first suggestion is that yes it requires 2.2 which is a pain and also you cant get over that 100Mb mark, I looked into this a lot as an option but theres still a ceiling on size which is a pain.

The 2nd suggestion sound like my only option but does anyone know of an example using this method? Or any other information relating to it?

Thanks
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Re: Large Applications

Postby blundell » Tue Oct 19, 2010 2:09 pm

You will be hard pushed to find an example without defining your problem more specifically.

When do you download the extra data? download it all when the app is first launched? Each time you dstart a new level, download it? Each time you press a button you load a section / object / item / all? You need to decide your design and implementation first.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Re: Large Applications

Postby tttcowan » Tue Oct 19, 2010 2:25 pm

Sorry for not being more specific, I have two options,

1. It would download the extra data on the first time of running the app.
2. It would download the extra data as an option on the first menu screen the user see, eg
" Start Game
Instructions
Download Soundpack
Options"

Either of the above could work for what I had in mind and they both rely on similair implementations... Is there any other info you'd need? I'm trying to think, the files wouldn't need to be decompressed or anything as they'll be in mp3 already.

Thansk again
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Re: Large Applications

Postby blundell » Tue Oct 19, 2010 2:54 pm

Code: Select all
  private static boolean downloadFromUrl(String videoUrlName, String fileName, Context context) {
                try {
                        URL url = new URL(videoUrlName);
                       
                        /* Open a connection to that URL. */
                        URLConnection ucon = url.openConnection();
                        /*
                         * Define InputStreams to read from the URLConnection.
                         */
                        InputStream is = ucon.getInputStream();
                        BufferedInputStream bis = new BufferedInputStream(is);
                        /*
                         * Read bytes to the Buffer until there is nothing more to read(-1).
                         */
                        ByteArrayBuffer baf = new ByteArrayBuffer(50);
                        int current = 0;
                        while ((current = bis.read()) != -1) {
                                baf.append((byte) current);
                        }

                        /* Convert the Bytes read to a String. */
                        FileOutputStream fos = null;
                        // Select storage location // External                                               
                                 File path = null; // TODO HERE you need to get the path to whereever you want to store
                                 // i.e. external storage. Don't forget to check that it is mounted
                                 File file = new File(path, fileName);
                                 fos = new FileOutputStream(file);
                        }                       
                        fos.write(baf.toByteArray());
                        fos.close();
                        //Log.d(GymApplication.TAG, fileName+" downloaded");

                } catch (IOException e) {
                        Log.e(GymApplication.TAG, "Error: " + e);
                        return false;
                }  catch (NullPointerException e) {
                        Log.w(GymApplication.TAG, "Error: " + e);
                        return false;
                }
                return true;
        }


This isn't the full answer, notice the TODO right in the middle, sorry haven't got the time at the moment for a better solution!
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Re: Large Applications

Postby tttcowan » Tue Oct 19, 2010 3:00 pm

That's great mate, thanks!
tttcowan
Developer
Developer
 
Posts: 46
Joined: Mon Jul 19, 2010 11:08 pm

Top

Return to General

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests