[android-developers] multicast permission of dalvik and how to attach to dalvik env?

2009-09-16 Thread caval
Hi all,

1.   I have a c lib which will send & receive multicast package, if I
lauch it in native ap, everything is OK, but if lauched through jni ,so it
run in
dalvik env, it can not receive multicast, i think is may be disabled by
dalvik, is there any permission can enable this feature?

2.   In this lib i will make some callback of function in dalvik class.
according to tranditional method which can run under JDK1.5 & 1.6
as follow: (I make it under source code env not NDK)

In some initialization method save jvm pointer

*int nRt = env->GetJavaVM(&jvm);*

some callback func in lib:

* **nResult = jvm->AttachCurrentThread((void **)&env, NULL);*
*
*
* **if ((nResult != 0) || (env == NULL))*
* **{*
* **return;*
* **}*
*
*
* **jstring res = env->NewStringUTF(srvName);  // failed*

*jclass cls = env->FindClass("com/xxx/ooo/ServerList");*

   * ...*
*
*
*jvm->DetachCurrentThread();*


it seems AttachCurrentThread not failed but env not correct.

Regards,
Caval.

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



[android-developers] Re: JNI callback problem

2009-09-15 Thread caval
Thanks for your tip, but the options does not work.may be I should check
android JNI spec firstly.

2009/9/16 fadden 

>
> (1) This discussion should be on android-ndk.
> (2) Make sure you have CheckJNI enabled (setprop dalvik.vm.checkjni
> true) if you're not on the emulator.
> (3) The logcat output will have some information about the crash that
> you should include.
>
>
> On Sep 15, 3:33 am, caval  wrote:
> > firstly I save JVM pointer in a native function which called when ap
> > lauched:
> > JNIEXPORT void JNICALL Java_com_caval_ServerList_Init
> >   (JNIEnv * env, jobject obj)
> > {
> > ...
> >
> > *// save jvm pointer*
> > * **int nRt = env->GetJavaVM(&jvm);*
> >
> > if (nRt == 0)
> > fprintf(stdout, "InitDLNACP --> GetJavaVM Success...\n");
> > else
> > fprintf(stderr, "InitDLNACP --> GetJavaVM Failed...\n");
> >
> > }
> >
> > then, when some event echoed I will make a callback of some class in jvm
> >
> > void _callback()
> > {
> > JNIEnv *env = NULL;
> > int nResult = -1;
> >
> > *nResult = jvm->AttachCurrentThread((void **)&env, NULL);*
> > *if ((nResult != 0) || (env == NULL))*
> > {
> > fprintf(stderr, "--> In _Java_com_caval_now_Map_AddItem Thread Attached
> > Failed.\n");
> > return;
> >
> > }
> >
> > jstring ret = env->NewStringUTF(pszTitle); // I run to this line and ap
> > crashed.
> > jclass cls = env->FindClass("com/caval/now/ServerList");
> >
> > }
> >
> > the AttachCurrentThread func return OK and also I get the env pointer.
> > but any call on env will crash.
> >
> > I have no idea of this issue...any help will highly appriciated.
> >
> > Regards,
> > Caval.
> >
>

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



[android-developers] JNI callback problem

2009-09-15 Thread caval
firstly I save JVM pointer in a native function which called when ap
lauched:
JNIEXPORT void JNICALL Java_com_caval_ServerList_Init
  (JNIEnv * env, jobject obj)
{
...

*// save jvm pointer*
* **int nRt = env->GetJavaVM(&jvm);*

if (nRt == 0)
fprintf(stdout, "InitDLNACP --> GetJavaVM Success...\n");
else
fprintf(stderr, "InitDLNACP --> GetJavaVM Failed...\n");
}

then, when some event echoed I will make a callback of some class in jvm

void _callback()
{
JNIEnv *env = NULL;
int nResult = -1;

*nResult = jvm->AttachCurrentThread((void **)&env, NULL);*
*if ((nResult != 0) || (env == NULL))*
{
fprintf(stderr, "--> In _Java_com_caval_now_Map_AddItem Thread Attached
Failed.\n");
return;
}

jstring ret = env->NewStringUTF(pszTitle); // I run to this line and ap
crashed.
jclass cls = env->FindClass("com/caval/now/ServerList");
}

the AttachCurrentThread func return OK and also I get the env pointer.
but any call on env will crash.

I have no idea of this issue...any help will highly appriciated.

Regards,
Caval.

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



[android-developers] Re: Catching memory exception

2009-08-04 Thread caval
Firstly you can enter into the shell mode by typing "adb shell"then because
android has a linux heart so you can type "ps"
to see all process's status which also including mem info.

Regards,
Caval.

2009/8/5 whitech 

>
> Oh so sorry to hear that
> Thank you.
> There's another problem, is there some way to know how many memory my
> program is using ?
>
> On 8月4日, 下午6时39分, Mark Murphy  wrote:
> > whitechwrote:
> > > There is another problem, can I push the limit of memory higher? It is
> > > a little too small with only 16 MB
> >
> > Not without changing the firmware.
> >
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|
> http://twitter.com/commonsguy
> >
> > Android Training in Germany, 18-22 January 2010:http://bignerdranch.com
> >
>

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