SurfaceViews handling, Thread, and general game design

by Dianne Hackborn » Wed, 15 Jul 2009 00:06:43 GMT


Sponsored Links
  very strongly recommend that you don't use multiple surface views.  A
surface view is a very heavy-weight object, and intended for the primary
area of the window -- for example, the video part of a video player, the
playfield of a game, etc. It is basically an overlay, and actually its own
separate full window that is simply being Z-ordered with your main window to
make it look like they are related.

I don't know what your "complicated" animation sequence is, but just having
some animation is not enough reason to use a surface view. Worst case, you
can just create an off-screen bitmap that you draw the animation in and
update the screen by drawing that bitmap to the screen with the normal
invalidate() mechanism. If you need the performance of a surface view, then
you should design your game so that your entire playfield is on surface
view, and you take care of drawing each of your boxes inside of that and
manage them however you want (not as their own views).

On Tue, Jul 14, 2009 at 4:27 AM, ayanir <ayanir...@gmail.com> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. need help on https (code for http included)

thank you droidin,

unfortunately I didnt need the httpclient but the stream.

well, I found a solution :)

btw: this is sdk 1.1 r1 code:

greetings,
marco

------------------------------------------------------------------------
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import lgpl.haustein.Base64Encoder;

import org.apache.log4j.Appender;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Layout;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

/**
 * Hyper
 */
public class Hyper extends Activity {

        private static Logger logger = Logger.getLogger(Hyper.class);

        private static final String HTTP = "http://www.gmx.de";
        private static final String HTTPS = "https://www.verisign.com/";

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                logger.debug("START");

                try {
                        SSLContext sc = SSLContext.getInstance("TLS");
                        scinit(null, new TrustManager[] { new MyTrustManager() 
}, new
SecureRandom());
                        
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
                        HttpsURLConnection.setDefaultHostnameVerifier(new 
MyHostnameVerifier());
                        HttpsURLConnection con = (HttpsURLConnection) new
URL(HTTPS).openConnection();
                        con.setDoOutput(true);
                        con.setDoInput(true);
                        con.connect();

                        BufferedReader br = new BufferedReader(new
InputStreamReader(con.getInputStream()));
                        StringBuffer sb = new StringBuffer();
                        String line;
                        while ((line = br.readLine()) != null)
                                sb.append(line);

                        logger.debug("InputStream: " + sb.toString());

                        logger.debug("END");
                } catch (Exception e) {
                        logger.error(e);
                }
        }

        /**
         * MyHostnameVerifier
         */
        private class MyHostnameVerifier implements HostnameVerifier {

                @Override
                public boolean verify(String hostname, SSLSession session) {
                        return true;
                }
        }

        /**
         * MyTrustManager
         */
        private class MyTrustManager implements X509TrustManager {

                @Override
                public void checkClientTrusted(X509Certificate[] chain, String 
authType) {
                }

                @Override
                public void checkServerTrusted(X509Certificate[] chain, String 
authType) {
                }

                @Override
                public X509Certificate[] getAcceptedIssuers() {
                        return null;
                }
        }

}
------------------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~

2. Intercepting SQLite's file reads / writes, so we can encrypt the storage

Ok, Androids, I have an odd question on SQLite's file storage.

We have a need to encrypt the data stored within SQLite.  The obvious
approach would be to encrypt individual records before storing them in
the table, but that will melt down.  For example, if we want to search
for a string, we would have to actually retrieve everything in the
table and decrypt all of it to find the string.  Doing a join seems
like it would be impossible.  We're not even going to explore or
consider that route.

I know that SQLite stores all the data in a single flat file.  I
assume that it accesses that file by MemoryMappedFile or something
like that.  My idea is to create a sub-class of MemoryMappedFile that
does block encryption / decryption on write / read.  Doing so would be
quite efficient, and lets us use SQLite as normal.  We would somehow
have to pass that special encrypted MemoryMappedFile to SQLite when
the instance is constructed.

But I've never done this before and don't really know any of these
internals.  Does anyone have some insight on where to begin on that?

Thanks

--~--~---------~--~----~------------~-------~--~----~

3. how to integrate audio file with seekbar

4. Remove or hide scroll bar on webview

5. setImageBitmap issue

6. Any else having problems with Market publishers site?

7. How calculates memory usage of application