[android-developers] In a Native C program, how to call java API: ActivityManager::getMemoryInfo()
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; spIServiceManager sm = defaultServiceManager(); spIBinder 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 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] A simplest Application access Content Provider
hi, Usually, we can inherit class Activity to access Content Provider, such as SMS/Contacts with following codes: === public class ActivityTest extends Activity { ... private void insertSms(String str_address, String content){ ContentResolver contentResolver = getContentResolver(); String strUriInbox = content://sms/inbox; ContentValues values = new ContentValues(); values.put(address, str_address); values.put(date, Calendar.getInstance().getTime().getTime()); values.put(protocol, 0); values.put(status, -1); values.put(type, 1); values.put(body, content); Uri uriSms = Uri.parse(strUriInbox); contentResolver.insert(uriSms, values); } } === However, I don't want to show a activity if write SMS database. So, I design a simplest application without Activity with following codes: === package com.xxx.NoActivityTest; public class NoActivityTest { public NoActivityTest(){ } private void insertSms(String str_address, String content){ ContentResolver contentResolver = *getContentResolver*(); *//NoActivityTest don't inherit from Activity, so, don't recongnize getContentResolver(), so, can't get ContentResolver instance.* String strUriInbox = content://sms/inbox; ContentValues values = new ContentValues(); values.put(address, str_address); values.put(date, Calendar.getInstance().getTime().getTime()); values.put(protocol, 0); values.put(status, -1); values.put(type, 1); values.put(body, content); Uri uriSms = Uri.parse(strUriInbox); contentResolver.insert(uriSms, values); } public static void main(String[] args) { NoActivityTest ex = new NoActivityTest(); ex.insertSms(13912345678, test0001); } } === As you seen from comments, can't get ContentResolver instance because don't recongnize getContentResolver(). How to overcome this issue? Thanks. -- 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: [android-kernel] A simplest Application access Content Provider
Sorry, I've corrected it. If you have any idea about this issue, please help check it. Thanks. 2010/5/5 Mateusz Kozak mateuszkozak...@gmail.com Why are you posting this on Android-kernel not on android-platform? W dniu 2010-05-05 13:57 użytkownik linlo...@gmail.com napisał: hi, Usually, we can inherit class Activity to access Content Provider, such as SMS/Contacts with following codes: === public class ActivityTest extends Activity { ... private void insertSms(String str_address, String content){ ContentResolver contentResolver = getContentResolver(); String strUriInbox = content://sms/inbox; ContentValues values = new ContentValues(); values.put(address, str_address); values.put(date, Calendar.getInstance().getTime().getTime()); values.put(protocol, 0); values.put(status, -1); values.put(type, 1); values.put(body, content); Uri uriSms = Uri.parse(strUriInbox); contentResolver.insert(uriSms, values); } } === However, I don't want to show a activity if write SMS database. So, I design a simplest application without Activity with following codes: === package com.xxx.NoActivityTest; public class NoActivityTest { public NoActivityTest(){ } private void insertSms(String str_address, String content){ ContentResolver contentResolver = *getContentResolver*(); *//NoActivityTest don't inherit from Activity, so, don't recongnize getContentResolver(), so, can't get ContentResolver instance.* String strUriInbox = content://sms/inbox; ContentValues values = new ContentValues(); values.put(address, str_address); values.put(date, Calendar.getInstance().getTime().getTime()); values.put(protocol, 0); values.put(status, -1); values.put(type, 1); values.put(body, content); Uri uriSms = Uri.parse(strUriInbox); contentResolver.insert(uriSms, values); } public static void main(String[] args) { NoActivityTest ex = new NoActivityTest(); ex.insertSms(13912345678, test0001); } } === As you seen from comments, can't get ContentResolver instance because don't recongnize getContentResolver(). How to overcome this issue? Thanks. -- unsubscribe: android-kernel+unsubscr...@googlegroups.comandroid-kernel%2bunsubscr...@googlegroups.com website: http://groups.google.com/group/android-kernel -- unsubscribe: android-kernel+unsubscr...@googlegroups.comandroid-kernel%2bunsubscr...@googlegroups.com website: http://groups.google.com/group/android-kernel -- 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] SGX driver impact Android phone
hi In latest Android phone, SGX driver has replaced framebuffer. However I find frameworks/base/opengl/tests/swapinterval/swapinterval.cpp don't work well, the error output is as blow: == C:\adb shell test-opengl-swapinterval # configs = 27 couldn't find an EGLConfig matching the screen format == And then I try two solutions: 1. If I delete THREE so libs: /system/lib/hw/gralloc.omap3.so, /system/lib/egl/libGLESv1_CM_POWERVR_SGX530_121.so, /system/lib/egl/libEGL_POWERVR_SGX530_121.so, test-opengl-swapinterval will work well. However, it will cause the phone screen can't show normally. 2. run adb shell stop, and then run test-opengl-swapinterval, it work well. however, it will cause the phone screen can't show normally. So, Could you tell me how to build and run it without delete these THREE so libs, and without run adb shell stop? Thanks. -- 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] After call fork(), sub-process can't be executed
hi, In recent release of Android, I suddenly find the fork() will NOT run sub-process once parent-process exit. For example, following program will only output main(), not output sub-process continue: printf(main()\n); pid_t pid = fork(); if(pid 0) { return -1; }else if(pid 0){ exit(0); } setsid(); printf(sub-process continue\n); Maybe parent-process exit too fast, so, I add a sleep to delay parent-process exit. So, test following program: printf(main()\n); pid_t pid = fork(); if(pid 0) { return -1; }else if(pid 0){ printf(parent-process exit\n); usleep(500); exit(0); } setsid(); printf(sub-process continue\n); In most results, will output following: main() parent-process exit sub-process continue However, sometimes still can't run sub-process, output following: main() parent-process exit Do you know what happen? Thanks. -- 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] How to get all the log from phone reboot to IDLE
hi, I want to get all the log info from phone reboot to enter IDLE screen. Using this reboot log info, I can debug some initialized prcocess. Thanks. -- 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] When issue adb shell sendevent, I don't want ADB server redirect any printf's info to terminal at Windows CMD.
As you know, when issue adb shell sendevent, the printf of sendevent will write to /dev/pts/1, and at that time, ADB server will read from /dev/ptmx. Finally, the printf of sendevent will show at Windows CMD. But, I don't want any printf's info is shown at Windows CMD. How to do at sendevent? Currently, I have added following codes at sendevent: - close(0); close(1); close(2); sleep(10); - But, Windows CMD still wait 10 second, and then over adb shell sendevent. Because sendevent will consume more than 10 seconds, I wish sendevent can close output device, and then ADB server immediately stop read, and then Windows CMD immediately finish wait status, and Windows CMD can input any other commands by person. How to do that? Thanks. --~--~-~--~~~---~--~~ 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: When issue adb shell sendevent, I don't want ADB server redirect any printf's info to terminal at Windows CMD.
My real requirement is that: sendevent will consume more than 10 seconds, so, I wish Windows CMD don't wait so long, and Windows CMD can immediately return to user-input-status. Currently I can bethink of calling close(), likely as belows: - close(0); close(1); close(2); sleep(10); - But fail, because Windows CMD still wait 10 second to return. Do you have any other way? Or, where is wrong about above implementation? Thansk. 2009/3/24 David Turner di...@android.com Why don't y ou try to redirect the output of adb shell to the NUL device instead ? On Tue, Mar 24, 2009 at 4:22 AM, linlo...@gmail.com wrote: As you know, when issue adb shell sendevent, the printf of sendevent will write to /dev/pts/1, and at that time, ADB server will read from /dev/ptmx. Finally, the printf of sendevent will show at Windows CMD. But, I don't want any printf's info is shown at Windows CMD. How to do at sendevent? Currently, I have added following codes at sendevent: - close(0); close(1); close(2); sleep(10); - But, Windows CMD still wait 10 second, and then over adb shell sendevent. Because sendevent will consume more than 10 seconds, I wish sendevent can close output device, and then ADB server immediately stop read, and then Windows CMD immediately finish wait status, and Windows CMD can input any other commands by person. How to do that? Thanks. --~--~-~--~~~---~--~~ 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] How to lighten LED in key driver, when user press any KEY.
hi, In G1 phone, when user press any KEY, the LED that be as backlight of HOME KEY, will be lightened. I check Android source codes, and want to know how to lighten the LED in key driver, but, don't find any clue. I have checked following source codes: -- kernel/drivers/input/ kernel/drivers/leds/ --- My key question is that where in the codes of key driver, will call LED driver to control LED on/off. Thanks. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---