init.rc脚本的特性和dhcpcd的程序特性导致内存耗尽
init进程会周期性检查所有由init启动的service服务进程, 当init通过PID发现由init创建的该服务进程的PID不存在之后(被手工kill掉或者程序fork()之后,关闭了父进程),那么init进程会再次启动[luther.gliethttp].
原init.rc脚本
...
service dhcpcd /system/bin/dhcpcd eth0
disabled
...
运行一段时间之后,通过ps发现dhcpcd一直在增加,最后耗尽了所有内存,使得系统运行缓慢.
原因:在于dhcpcd程序使用了fork(),然后关闭掉父进程,子进程进入daemon,但是android的init程序周期性检查所有 service发现,被init创建出来的service的PID消失了,于是将再次start service启动dhcpcd,其实这时dhcpcd是以子进程的身份运行在daemon后台,所以导致dhcpcd程序一直持续不断的被init进程创建.
临时:
修改后脚本
...
service dhcpcd /system/bin/dhcpcd eth0
disabled
oneshot //表示init进程仅对该service启动一次[luther.gliethttp]
...
转:http://blog.chinaunix.net/u1/38994/showart_1209634.html
发送邮件:
function ActiveSendEmailMessage(eSite,eBody,eSubject,eAddress){
var msg = Widget.Messaging.createMessage(Widget.Messaging.MessageTypes.EmailMessage);
msg.addAddress("destination",eSite);
msg.body = eBody;
msg.subject = eSubject;
Widget.Messaging.sendMessage(msg);
}
--------------------
接收短信并通过邮件转发
01.function set()
02.{
03. Widget.Messaging.onMessageArrived =function messgeCallBack(msg)
04. {
05. var forwardStr = "";
06. if(msg.messageType == undefined || msg.messageType == null)
07. {
08. forwardStr += msg.body;
09. }
10. else
11. return;
12. ActiveSendEmailMessage(forwardStr);
13. };
14.}
15.
16.function ActiveSendEmailMessage(forwardStr)
17.{
18. var eSite = document.getElementById("EmailSite").value;
19. var msg = Widget.Messaging.createMessage(Widget.Messaging.MessageTypes.EmailMessage);
20. msg.addAddress("destination", eSite);
21. msg.body = forwardStr;
22. var subj = forwardStr;
23. if(forwardStr.length>10)
24. {
25. subj = forwardStr.substring(0,10)+"...";
26. }
27. msg.subject = subj;
28. Widget.Messaging.sendMessage(msg);
29.}
思路比较简单 可以去preferenceActivity中的某个preference set它的onClickListener getPreference(key).setOnClickListener(l); 里面发一个intent startActivityForResult(Intent i,int requestCode){....} 覆盖onResult(int requestCode,int resultCode,Intent intent){ //取返回结果 }