E
Sent from my Verizon Wireless Phone

-----Original message-----
From: Sandeep Patil <[email protected]>
To:
Android Developers <[email protected]>
Sent:
Tue, Jun 7, 2011 22:07:23 GMT-03:00
Subject:
[android-developers] Unable to use the surface object from application side in the native side.

Dear frndz,

I am facing a problem of being not able to use the surface object
obtained from an activity class in the native side. Here is what i am
doing,

* Getting a SurfaceView object with the help of findviewbyId()
function.
* Then obtaining its SurfaceHolder by calling getHolder() function of
the surfaceView class.
* Then adding a callback to the holder, so as to know when the surface
is being created and destroyed.
* Once i get the callback of onSurfaceCreated(), i am getting the
surface object by getSurface() of the SurfaceHolder class and setting
it to a (Surface mSUrface = null ) field in the Activity class.
* From onSurfaceCreated() itself, I am calling a native function that
tries to access the mSurface object and casts it to sp.

Here is my native function,

JNIEXPORT void JNICALL setSurface(JNIEnv* env,jobject thiz)
{
jfieldID surfacefieldID;
jfieldID surface_native;
Surface* p;
jclass clazz;

clazz = env->FindClass("com/example/SMFMediaPlayer/
SecondActivity");
if (clazz == NULL) {
LOGE("Can't find com/example/SMFMediaPlayer/SecondActivity
\n");
}

surfacefieldID = env->GetFieldID(clazz, "mSurface", "Landroid/view/
Surface;");
if (surfacefieldID == NULL) {
LOGE("Can't find MediaPlayer.mSurface\n");
}

jclass surface = env->FindClass("android/view/Surface");
if (surface == NULL) {
LOGE("Can't find android/view/Surface\n");
}

surface_native = env->GetFieldID(surface, "mSurface", "I");

if (surface_native == NULL) {
LOGE("Can't find Surface fields\n");
}

jobject surfaceobj = env->GetObjectField(thiz,surfacefieldID);
if (surfaceobj != NULL)
{
p = (Surface*) env->GetIntField(surfaceobj, surface_native);

if(p->isValid())
{
const sp& native_Surface = sp(p);
}
}
.
//There some more code down here



}




The problem here is that the execution is stopping at the
statement,"const sp& native_Surface = sp(p);".

I am not getting what is the mistake.

Actually i am using this code create my own media player. So i request
to let me know my mistake or an alternative way to access the surface
object. And also i need the SurfaceComposerClient object corresponding
the surface object.

SOmebody help me out.

Thanks You
Sandeep Patil

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<<inline: ic_list_money_mouth.png>>

Reply via email to