Compiling against a *REAL* android.jar in eclipse???

by Peter Carpenter » Tue, 28 Apr 2009 10:30:16 GMT


Sponsored Links
 Hello everyone,

 

I'd like to be able to extend classes like View and still have access to
the protected member variables.

Under the standard SDK's, android.jar is only a stub and so access to
the protected member variables is not found.  (And also all classes
tagged as {hide} are hidden)


Does anyone know of an easy way to get around/FIX this without going
linux?

 

Cheers,

 

Peter.


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



Compiling against a *REAL* android.jar in eclipse???

by Peter Carpenter » Tue, 28 Apr 2009 11:14:12 GMT


 Hi Dianne,

 

Thanks for replying.

 

I want to create custom GUI components and access things like
View.mScrollX which has no setFunction (to create a horizontally
scrolling view), and mBGDrawable which does have a set function - but
that does a whole heap of stuff I don't want it to do.

 

Essentially with the second option, I would like to have an image button
using all of the standard background drawables (but hide only the
default standard enabled state image).  I can't find API's that let me
do any of this cleanly.  The only way I can currently find is to
intercept the draw function and hide the background temporarily.  It
would be nicer to be able to either create my own StateListDrawable
using the existing button background drawables (which are not public) or
else have a removeState function in the StateListDrawable.

 

So essentially you are saying I shouldn't be doing this???

 

Cheers,


Peter.

 

________________________________

From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Dianne
Hackborn
Sent: Tuesday, 28 April 2009 1:02 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Compiling against a *REAL* android.jar
in eclipse???

 

Don't do that.  If you aren't writing an app but system code, use the
platform build system.

On Mon, Apr 27, 2009 at 7:29 PM, Peter Carpenter



Hello everyone,

 

I'd like to be able to extend classes like View and still have access to
the protected member variables.

Under the standard SDK's, android.jar is only a stub and so access to
the protected member variables is not found.  (And also all classes
tagged as {hide} are hidden)


Does anyone know of an easy way to get around/FIX this without going
linux?

 

Cheers,

 

Peter.

 

 




-- 
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.




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


Sponsored Links


Other Threads

1. Interleaved buffer in OpenGL incompatible with GLLogWrapper?

I'm getting exceptions when I try to use an interleaved buffer in
OpenGL with android.opengl.GLLogWrapper. Has anyone else run into
this?

Everything works fine if I disable GLLogWrapper by removing this line:
mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR |
GLSurfaceView.DEBUG_LOG_GL_CALLS);

Replacing that line with this also works fine:
mGLSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR);

What I'm doing seems fine to OpenGL, just not GLLogWrapper. Using
position() on Buffer to specify an offset is outlined here:
http://java.sun.com/javame/reference/apis/jsr239/

Same results on my Android 1.6 G1 and the emulator running an Android
2.0.1 AVD. Stack trace from 2.0.1:
V/GLSurfaceView(  226): glClear(GL_COLOR_BUFFER_BIT);
I/ARMAssembler(   54): generated
scanline__00000077:03010104_00000004_00000000 [ 22 ipp] (41 ins) at
[0x504b80:0x504c24] in 679333 ns
W/dalvikvm(  226): threadid=15: thread exiting with uncaught exception
(group=0x4001b188)
E/AndroidRuntime(  226): Uncaught handler: thread GLThread 8 exiting
due to uncaught exception
E/AndroidRuntime(  226): java.lang.IndexOutOfBoundsException
E/AndroidRuntime(  226):        at java.nio.IntToByteBufferAdapter.get
(IntToByteBufferAdapter.java:155)
E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.doArrayElement
(GLLogWrapper.java:1105)
E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.doElement
(GLLogWrapper.java:1126)
E/AndroidRuntime(  226):        at android.opengl.GLLogWrapper.glDrawArrays
(GLLogWrapper.java:1520)
E/AndroidRuntime(  226):        at
name.nanek.test.interleavedbuffer.TestInterleavedBuffer$1.onDrawFrame
(TestInterleavedBuffer.java:75)
E/AndroidRuntime(  226):        at android.opengl.GLSurfaceView
$GLThread.guardedRun(GLSurfaceView.java:1112)
E/AndroidRuntime(  226):        at android.opengl.GLSurfaceView$GLThread.run
(GLSurfaceView.java:971)
I/Process (   54): Sending signal. PID: 226 SIG: 3
I/dalvikvm(  226): threadid=7: reacting to signal 3

I can also get a slightly different exception if I modify the code to
slice the buffer at zero and position the slice:
V/GLSurfaceView(26498): glClear(GL_COLOR_BUFFER_BIT);
W/dalvikvm(26498): threadid=15: thread exiting with uncaught exception
(group=0x4001da28)
E/AndroidRuntime(26498): Uncaught handler: thread GLThread exiting due
to uncaught exception
E/AndroidRuntime(26498): java.nio.BufferUnderflowException
E/AndroidRuntime(26498):        at java.nio.IntToByteBufferAdapter.get
(IntToByteBufferAdapter.java:148)
E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.toByteBuffer
(GLLogWrapper.java:977)
E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.access$000
(GLLogWrapper.java:38)
E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper
$PointerInfo.bindByteBuffer(GLLogWrapper.java:3042)
E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.bindArrays
(GLLogWrapper.java:1147)
E/AndroidRuntime(26498):        at
android.opengl.GLLogWrapper.startLogIndices(GLLogWrapper.java:1166)
E/AndroidRuntime(26498):        at android.opengl.GLLogWrapper.glDrawArrays
(GLLogWrapper.java:1518)
E/AndroidRuntime(26498):        at
name.nanek.test.interleavedbuffer.TestInterleavedBuffer$1.onDrawFrame
(TestInterleavedBuffer.java:75)
E/AndroidRuntime(26498):        at android.opengl.GLSurfaceView
$GLThread.guardedRun(GLSurfaceView.java:955)
E/AndroidRuntime(26498):        at android.opengl.GLSurfaceView$GLThread.run
(GLSurfaceView.java:887)
I/Process (   76): Sending signal. PID: 26498 SIG: 3
I/dalvikvm(26498): threadid=7: reacting to signal 3

Here's some minimal sample code for the first case that uses robot.png
from the API Demos. Paste bin version:
http://pastebin.com/f3eb6b1d3

Inline version:
package name.nanek.test.interleavedbuffer;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLSurfaceView;
import android.opengl.GLUtils;
import android.opengl.GLSurfaceView.Renderer;
import android.os.Bundle;

public class TestInterleavedBuffer extends Activity {

        private static final boolean LOG = true;

        private static final boolean AUTOSLICE = false;

        //One in fixed point.
        private static final int F1 = 1 << 16;

        //Number of vertexes needed for a square made using a triangle strip.
        private static final int VERTEX_COUNT = 4;

        //3 position values and 2 texture values per vertex.
        private static final int INTS_PER_VERTEX = 5;

        //Byte distance between vertexes.
        private static final int STRIDE = INTS_PER_VERTEX * Integer.SIZE /
Byte.SIZE;

        //Total number of bytes.
        private static final int BUFFER_BYTES = VERTEX_COUNT * STRIDE;

    private final IntBuffer buffer = ByteBuffer
                .allocateDirect(BUFFER_BYTES)
                .order(ByteOrder.nativeOrder())
                .asIntBuffer();
        {
                buffer.put(new int[] {
                        0, F1, 0, 0, 0,//Top left.
                        0, 0, 0, 0, F1,//Bottom left.
                        F1, F1, 0, F1, 0,//Top right.
                        F1, 0, 0, F1, F1//Bottom right.
                });
                buffer.rewind();
        }

    private GLSurfaceView mGLSurfaceView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mGLSurfaceView = new GLSurfaceView(this);
        setContentView(mGLSurfaceView);

        if ( LOG ) {
                //Enabling this causes an exception.
                mGLSurfaceView.setDebugFlags
(GLSurfaceView.DEBUG_CHECK_GL_ERROR |
GLSurfaceView.DEBUG_LOG_GL_CALLS);
        } else {
                //This works fine.
                mGLSurfaceView.setDebugFlags
(GLSurfaceView.DEBUG_CHECK_GL_ERROR);
        }

        mGLSurfaceView.setRenderer(new Renderer() {

                        @Override
                        public void onDrawFrame(GL10 gl) {
                        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
                        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0,
VERTEX_COUNT);
                        }

                        @Override
                        public void onSurfaceChanged(GL10 gl, int width, int 
height) {
                        gl.glViewport(0, 0, width, height);
                        gl.glMatrixMode(GL10.GL_PROJECTION);
                        gl.glLoadIdentity();
                        gl.glOrthox(0, F1, 0, F1, 0, F1);
                        gl.glMatrixMode(GL10.GL_MODELVIEW);
                        }

                        @Override
                        public void onSurfaceCreated(GL10 gl, EGLConfig config) 
{
                        gl.glColor4x(F1, F1, F1, F1);
                        gl.glClearColorx(F1, F1, F1, F1);
                        gl.glEnable(GL10.GL_TEXTURE_2D);
                        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
                        gl.glVertexPointer(3, GL10.GL_FIXED, STRIDE, buffer);
                        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

                        //Skip first 3 position values to get to texture
coordinates.
                        buffer.position(3);

                        //Both options here cause an exception in GLLogWrapper.
                        if ( AUTOSLICE ) {
                                gl.glTexCoordPointer(2, GL10.GL_FIXED, STRIDE, 
buffer);
                        } else {
                                gl.glTexCoordPointer(2, GL10.GL_FIXED, STRIDE, 
buffer.slice
());

                        }
                        buffer.rewind();

                        int[] textures = new int[1];
                        gl.glGenTextures(1, textures, 0);
                        gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
                        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
                        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
                        Bitmap bitmap = 
BitmapFactory.decodeResource(getResources(),
R.drawable.robot);
                        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
                        bitmap.recycle();
                        }

        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLSurfaceView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLSurfaceView.onPause();
    }

}

2. PACKAGE_ADDED, PACKAGE_REMOVED and PACKAGE_REPLACED...

when I re-install an application, i get PACKAGE_REMOVED followed by
PACKAGE_ADDED.

I never see PACKAGE_REPLACED.  any ideas why?  And actually, I never
see any of the PACKAGE_* actions except in LogCast -- I cannot get my
broadcast receiver to get the events.

i'm doing this in the emulator using adb --

adb install -r MyApp.apk

My Android manifest has these lines in it:

<application...>
...
...
                <receiver android:name="com.test.MyApp.UpdateReceiver">
                    <intent-filter>
                        <action 
android:name="android.intent.action.PACKAGE_ADDED"/>
                        <action 
android:name="android.intent.action.PACKAGE_REMOVED"/>
                        <action 
android:name="android.intent.action.PACKAGE_REPLACED"/>
                    </intent-filter>
                </receiver>
...
...
</application>

And my UpdateReceiver.java looks like this:

package com.test.MyApp;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class UpdateReceiver extends BroadcastReceiver {

        @Override
        public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                System.err.println("action: " + action);
        }
}

tia.

-- 

3. open all blocked sites in your country now

4. who can give a summary about the strong reference and weak reference in Android

5. Large file (> 2GiB) support in bionic

6. Unable to get redraw of View

7. Documents regarding drivers/MMC