IMHO instead of dealing via JNI with the ActivityManager I from you
native
code I would create a java wrapper and your native code only interacts
with this wrapper . This allows you to provide an easier interface.

Good luck ! Frank


BTW : I think this kind of question is out of scope of this particular
group.



On 10 Mai, 13:41, [email protected] wrote:
> In Java program, we can use following codes to get the system memory info:
> ===============================================================
> ActivityManager activityManager = (ActivityManager)
> getSystemService(ACTIVITY_SERVICE);
> MemoryInfo info = new MemoryInfo();
> activityManager.*getMemoryInfo*(info);
> ===============================================================
>
> But now, we need to get system memory info from Native C program. So, I have
> to implement following codes to new "MemoryInfo" object:
> ===============================================================
>     jclass cls = env->FindClass("android/app/ActivityManager$MemoryInfo");
>     jmethodID ctor = env->GetMethodID(cls, "<init>", "()V");
>     jobject *objMemoryInfo* = env->NewObject(cls, ctor);
> ===============================================================
>
> Up to now, we have got the MemoryInfo's object "objMemoryInfo".
>
> Then I need to input "*objMemoryInfo*" to "*parcelMemoryInfo*", but don't
> how to convert from Parcelable to Parcel:
> ===============================================================
>     int GET_MEMORY_INFO_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION+75;
>
>     sp<IServiceManager> sm = defaultServiceManager();
>     sp<IBinder> am = sm->getService(String16("activity"));
>     Parcel *parcelMemoryInfo* = *objMemoryInfo*; * //HERE: how to convert
> from Parcelable to Parcel
> *    Parcel reply;
>     status_t ret = am->transact(GET_MEMORY_INFO_TRANSACTION, *
> parcelMemoryInfo*, &reply);
> ===============================================================
> Thanks.

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

Reply via email to