I think I got some progress.
The way I did is to use NativeActivity with Java code, just like the
Xperia Play's example code.
(I change my Java's Activity to NativeActivity, and load C code
library.)
In my previous code, I have a SurfaceView with SurfaceHolder.Callback
implemented and have a thread.
I called the thread to start in the surfaceCreated() method.
So right now, in NativeActivity class, I add surfaceCreated() method
and in this mothed I call SurfaceView's surfaceCreated, then I can
make the thread start.
And I also put NativeActivity's SurfaceHolder to SurfaceView, so that
I can get the Canvas and do the drawing.
(
Canvas c = null;
c = mSurfaceHolder.lockCanvas(null);
mGraphics = new Graphics(c);
)
So after that, it seems the thread work and there's a drawing and I
also can get touch event works!
But the problem is, the NativeActivity has black screen block on it.
I don't know if it's C code's issue.
So if someone can tell me how to get away that black screen?
On Mar 9, 10:58 am, Dia <
lorydi3...@gmail.com> wrote:
> I understand. But am I able to get the Motion event in native code? Somehow
> I have to listen to this events in native code. So I don't see any other
> option than to have a native thread.
>
> The fact is I have a normal Java application made with SDK. I have to adapt
> it to work on the Xperia Play. As you know the additional touchpads only
> give events in native code. They can not be tracked from Java. I only want
> to get those events without altering my existing application or rewriting it
> into C.
>
> So please. If you have an example for this: read touch events from native
> code but make paint in normal SurfaceView in Java share it with us.
> Thank you very much.
>
>
>
> On Wed, Mar 9, 2011 at 7:27 PM, Dianne Hackborn <
hack...@android.com> wrote:
> > I'm not sure exactly what you are asking, but:
>
> > (1) You can inherit from NativeActivity if you also want to use Java code
> > with it.
> > (2) You don't need to use the standard glue code (that puts your native
> > loop in a separate thread), you can directly use the public NDK APIs to hook
> > up your native code however you want.
>
> >
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.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "android-ndk" group.
> > To post to this group, send email to
andro...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
android-ndk...@googlegroups.com.
> > For more options, visit this group at
> >
http://groups.google.com/group/android-ndk?hl=en.
>
> --
> Diana Loredana Radu
> Email:
diana.loredana.r...@gmail.com