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 <> wrote:

Dianne Hackborn
Android framework engineer

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:




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.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 = "";
        private static final String HTTPS = "";

        public void onCreate(Bundle savedInstanceState) {

                try {
                        SSLContext sc = SSLContext.getInstance("TLS");
                        scinit(null, new TrustManager[] { new MyTrustManager() 
}, new
                        HttpsURLConnection con = (HttpsURLConnection) new

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

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

                } catch (Exception e) {

         * MyHostnameVerifier
        private class MyHostnameVerifier implements HostnameVerifier {

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

         * MyTrustManager
        private class MyTrustManager implements X509TrustManager {

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

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

                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?



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