Android next how to write a will never be out of the process KILL / service? System that is not subject to garbage collection (memory management) affected.
Reply:
How to implement a process will not be killed
http://ophonesdn.com/forum/archiver/tid-56.html
Reply:
Improve Android Service priority method
http://dev.wo.com.cn/bbs / redirect.jsp? tid = 10700 & goto = lastpost
Reply:
Improve the Service Priority
Android system for memory management has its own set of methods, in order to protect the system stable and orderly transportation letter, the system will automatically assign an internal control program memory usage. When the system feel that the current time with very limited resources, in order to guarantee some of the high-priority program to run, it will kill some of the procedures he considers unimportant or service to free up memory. This ensures that the user really useful program still run again. Service if you run into this situation, most will be killed. But if you increase the priority of Service can make him stay for a while, we can use setForeground (true) to set the priority of Service.
Why is the foreground? Default boot Service is marked as background, currently running Activity is generally labeled as foreground, which means you set the foreground to the Service that he and running Activity similar priority has been some improvement. When asked this does not guarantee that you have Service will never be killed, but improved his priority.
There is a way to give you a clearer presentation, enter $ SDK / tools to run the command
Copy to clipboard
Code:
# Adb shell dumpsys activity | grep oom_adj
Running Norm Proc # 6: oom_adj = 0 ProcessRecord {43635cf0 12689: com.roiding.netraffic/10028}
Running Norm Proc # 5: oom_adj = 7 ProcessRecord {436feda0 12729: com.android.browser/10006}
Running Norm Proc # 4: oom_adj = 8 ProcessRecord {4367e838 12761: android.process.acore/10016}
Running Norm Proc # 3: oom_adj = 8 ProcessRecord {43691cd8 12754: com.google.process.gapps/10000}
Running PERS Proc # 1: oom_adj = -12 ProcessRecord {43506750 5941: com.android.phone/1001}
Running PERS Proc # 0: oom_adj = -100 ProcessRecord {4348fde0 5908: system/1000}
Returned a lot of things, observations oom_adj, if it is greater than 8 in general is likely to be ready to get rid of belonging to backgroud, the smaller the value the higher the priority proof, the later is to kill time. You see phone program is -12, telephone calls, nothing else is done, and also able to answer the phone right now. There is also a -100, but also because it is a public pool system if he is finished, the system will hang you have to, hehe.
Reply:
Landlord song mean? Question and answer or?
Reply:
Reply:
Just looking for some information, is also leave notes or something.
Reply:
Nobody understood this problem?
Reply:
Daemon?
Reply:
This daemon that how the whole?
Reply:
android plus daemon. txt
http://wenku.baidu.com/view/8c6314707fd5360cba1adbc1.html
Reply:
Talk daemon
http://farsight.blog.51cto.com/1821374/379944
Reply:
Write to the.
So much stuff, it is possible to achieve only firmware development, application is not going to pondering.
Reply:
Methods
own program permanently written for Android / system / bin of
http://hi.baidu.com/mcu99/blog/item/954a511085280509203f2e3a.html
After the Android emulator running, / system directory is read-only attribute. If you want to spread their program to run in the directory, you will find not succeed. Of course, using the adb remount command to temporarily remove its read-only restriction, you can transfer files to the inside, but once the restart Android emulator, when again will find a terminal emulator adb shell into their own pass into the file after the restart was Clear out.
Of course, you can put files to / data folder, this folder can not remount to write, and then restart the simulator own file will not be emptied. But if I wanted a more underlying program, or boot process, each boot in the / data starts always seemed strange. Written procedures to make themselves better can enjoy the status of those proceedings Android comes with every run under system / bin directory. This can be achieved by adding their own code in the Android source code, and then re-make of the method.
First, according to the nature of your project, in the corresponding Android source location create a folder. For example, if I have this program and hardware-related, you can build in hardware called my_hardware folder, and then put their program source code on the inside, such as call hard.c.
Give this program to write a makefile file, so when you can make your program automatically find and compile it. A name is called Android.mk, not just from the name, otherwise make no understanding. Put this Android.mk and hard.c are placed my_hardware below.
# Android.mk file content, for example
LOCAL_PATH: = $ (call my-dir)
include $ (CLEAR_VARS)
LOCAL_SRC_FILES: = \
hard.c
LOCAL_PRELINK_MODULE: = false
LOCAL_MODULE: = myhard
include $ (BUILD_EXECUTABLE)
After doing this, the total return under Android source directory and execute make, if you have had before you make, then this process will soon be a few minutes of it. Because the last time make compared to the source changes very little, just added a folder and two files only. If this is the first time you make, it will be relatively slow, maybe takes about 1-2 hours, speed, and machine configuration should also be concerned.
After make a successful run emulator emulator with adb shell into the simulator terminal, cd / system / bin, you can find your program (note name is myhard, not hard, nor is my_hardware, the program generated by the above name here red font that line program control). And it will not be lost after the start again.
Reply:
Daemon process known as Wizard (daemon), generally start at system startup, and terminates when the system is turned off. No controlling terminal and run in the background. There are many such processes in the linux system.
Said the following about how to create a daemon.
(1) the use of the word file umask modified shield, with the number of permissions given to files, because the files may inherit certain permissions to be masked, and thus lose some functions, such as reading and writing.
(2) calls fork function to create a child process, and the parent process exits.
(3) call settid create a new session, the current process for the session leader, and close the control terminal.
(4) modify the process working directory to the root directory, chdir ("/").
(5) Turn off unneeded inherited from the parent process over the file descriptor.
(6) open / dev / null, null device, also known as the black hole that is written to or read anything to no avail. This device is a file and open with 0,1,2 three file descriptors, but for standard input, standard output and standard error of the operation had no effect. This part is not essential.
Following a routine use to say about this process.
# Include
# Include
# Include
# Include
# Include
int main ()
{
pid_t pid;
struct rlimit r;
int i;
/ / XXX step 1: set umask
umask (0);
/ / XXX setp 2: fork
if ((pid = fork ()) <0)
{
perror ("fork");
exit (0);
}
else if (pid! = 0)
{
exit (0);
}
/ / XXX step 3: setsid
setsid ();
/ / XXX step 4: chdir
chdir ("/");
/ / XXX step 5: close all open file descriptors
if (r.rlim_max == RLIM_INFINITY)
{
r.rlim_max = 1024;
}
for (i = 0; i{
close (i);
}
while (1)
{
}
return 0;
}
The above is the process of creating a daemon process, but wrote some books or daemon on the network, so that the code will be added between the third and fourth steps.
if ((pid = fork ()) <0)
{
perror ("fork");
exit (0);
}
else if (pid! = 0)
{
exit (0);
}
Many students will ask, why do you want to create two processes, this is because after the end of the third step, the process creates a new conversation group, and became leader of the session, and the session leader may gain control terminal, if obtained So the process control terminal or not the daemons. So add these few lines of code, so that the process of losing the identity of the session leader, and thus did not get permission to control terminals.
Reply:
Simple daemon should be able to write! ! !
Reply:
android using socket and make the underlying framework of communication
http://fanwei51880.blog.163.com/blog/static/32406740201011150240981/
Reply:
RIL is under an android communication through daemon to communicate with examples SOCKET! ! !
Reply:
Common 100 linux daemon
http://sunyu.blog.51cto.com/744725/320647
Reply:
Today, finally succeeded to write and implement a daemon start running, start the service can not be loaded because SERVICE NAME originally used too long, exceeded the limit 16
Reply:
Thank landlord's share
By the landlord's knowledge and this article http://blog.sina.com.cn/s/blog_4d66a3cb0100prfe.html
Finally achieve the goal. By adding android in androidmanifest.xml the application tag: persistent = "true" attribute indeed can be achieved after the application to ensure that the process will not be killed where LMK. But there is a premise that the application must be an application, that application can not be installed using the usual way. The application must apk package directly into the / system / app directory. And the system must be restarted to take effect after.
In addition to several general priority, but there are still coreserver, system this will never be recovered LMK priority. Telephone system is coreserver priority application.
That by viewing the source code, only the flag of the application is simultaneously FLAG_SYSTEM and FLAG_PERSISTENT, will be set to the priority
coreserver
if ((info.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_PERSISTENT))
== (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_PERSISTENT)) {
app.persistent = true;
app.maxAdj = CORE_SERVER_ADJ;
}
FLAG_SYSTEM apk put in an application / system / app will be set next. It appears only set android: case persistent = "true" will still be killed.
When testing found that the application into the / system / app without rebooting the system will still be recognized as a normal process. When the system is restarted, it will start at the outset of the process and put it priority to coreserver.
Which can obviously see the difference by dumpsys activity command.
Running processes (most recent first):
App # 3: adj = 2/1 ProcessRecord {30858c20 1877: com.android.email/10014} (started-services)
PERS # 2: adj = -100 / 0 ProcessRecord {308fb390 1713: system/1000} (fixed)
App # 1: adj = 0/0 ProcessRecord {30908198 1794: android.process.acore/10005} (top-activity)
PERS # 0: adj = -12 / 0 ProcessRecord {3090d488 1789: xiao.xiong.test/10026} (fixed)
And adj = -12, this process manually stop by after ddms starts immediately
Reply:
Also thank you for sharing! ! !
Reply:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C: \ Documents and Settings \ Administrator> adb shell
# Dumpsys activity
dumpsys activity
Sticky broadcasts:
* Sticky action android.media.RINGER_MODE_CHANGED:
Intent: act = android.media.RINGER_MODE_CHANGED flg = 0x70000000
Bundle [{android.media.EXTRA_RINGER_MODE = 2}]
* Sticky action android.intent.action.BATTERY_CHANGED:
Intent: act = android.intent.action.BATTERY_CHANGED flg = 0x60000000
Bundle [{icon-small = 17302169, present = true, scale = 100, level = 85, technology = Li-ion, status = 2, voltage = 8536, plugged
= 1, health = 2, temperature = 250}]
* Sticky action android.net.thrott.THROTTLE_ACTION:
Intent: act = android.net.thrott.THROTTLE_ACTION
Bundle [{level = -1}]
* Sticky action android.net.thrott.POLL_ACTION:
Intent: act = android.net.thrott.POLL_ACTION
Bundle [{cycleRead = 0, cycleStart = 1294358400000, cycleEnd = 1297036800000, cycleWrite = 0}]
Activity stack:
* TaskRecord {45f1a690 # 2 A com.android.launcher}
clearOnBackground = true numActivities = 1 rootWasReset = false
affinity = com.android.launcher
intent = {act = android.intent.action.MAIN cat = [android.intent.category.HOME] flg = 0x10000000 cmp = com.android.launcher / co
m.android.launcher2.Launcher}
realActivity = com.android.launcher/com.android.launcher2.Launcher
lastActiveTime = 3094388 (inactive for 1411s)
* Hist # 0: HistoryRecord {45efe298 com.android.launcher/com.android.launcher2.Launcher}
packageName = com.android.launcher processName = com.android.launcher
launchedFromUid = 0 app = ProcessRecord {45f1ab80 968: com.android.launcher/10010}
Intent {act = android.intent.action.MAIN cat = [android.intent.category.HOME] flg = 0x10000000 cmp = com.android.launch
er/com.android.launcher2.Launcher}
frontOfTask = true task = TaskRecord {45f1a690 # 2 A com.android.launcher}
taskAffinity = com.android.launcher
realActivity = com.android.launcher/com.android.launcher2.Launcher
base = / system/app/Launcher2.apk/system/app/Launcher2.apk data = / data / data / com.android.launcher
labelRes = 0x7f0c0002 icon = 0x7f020048 theme = 0x7f0d0000
stateNotNeeded = true componentSpecified = false isHomeActivity = true
configuration = {scale = 1.0 imsi = 0/0 loc = md_US touch = 3 keys = 2/1/2 nav = 3/1 orien = 2 layout = 35 uiMode = 17 seq = 2}
launchFailed = false haveState = false icicle = null
state = RESUMED stopped = false delayedResume = false finishing = false
keysPaused = false inHistory = true persistent = false launchMode = 2
fullscreen = true visible = true frozenBeforeDestroy = false thumbnailNeeded = false idle = true
waitingVisible = false nowVisible = true
Running activities (most recent first):
TaskRecord {45f1a690 # 2 A com.android.launcher}
Run # 0: HistoryRecord {45efe298 com.android.launcher/com.android.launcher2.Launcher}
mPausingActivity: null
mResumedActivity: HistoryRecord {45efe298 com.android.launcher/com.android.launcher2.Launcher}
mFocusedActivity: HistoryRecord {45efe298 com.android.launcher/com.android.launcher2.Launcher}
mLastPausedActivity: HistoryRecord {45f0ee48 com.KT.NDKOpenGL_AppSwitch / .NDKOpenGL_AppSwitch}
mCurTask: 5
Running processes (most recent first):
App # 12: adj = vis / F 45e23f30 963: com.android.inputmethod.latin/10022 (service)
com.android.inputmethod.latin.LatinIME <= ProcessRecord {45de0768 894: system/1000}
PERS # 11: adj = sys / F 45de0768 894: system/1000 (fixed)
App # 10: adj = fore / F 45f1ab80 968: com.android.launcher/10010 (top-activity)
App # 9: adj = bak / B 45e26a20 970: com.android.settings/1000 (bg-empty)
App # 8: adj = bak +1 / B 45e15af0 1029: android.process.media/10004 (bg-empty)
App # 7: adj = bak +2 / B 45df5ae8 1101: com.android.quicksearchbox/10015 (bg-empty)
App # 6: adj = bak +3 / B 45de2d80 1087: com.android.providers.calendar/10023 (bg-empty)
App # 5: adj = bak +4 / B 45fe5548 1076: com.android.bluetooth/10020 (bg-empty)
App # 4: adj = bak +5 / B 45fd7ea8 1058: com.android.email/10017 (bg-empty)
App # 3: adj = bak +6 / B 45f2d398 1019: com.android.deskclock/10000 (bg-empty)
App # 2: adj = bak +7 / B 45ef5280 1116: com.android.protips/10025 (bg-empty)
App # 1: adj = empty / B 45ebfa58 1109: com.android.music/10024 (bg-empty)
App # 0: adj = empty / B 45e64e20 999: android.process.acore/10005 (bg-empty)
PID mappings:
PID # 894: ProcessRecord {45de0768 894: system/1000}
PID # 963: ProcessRecord {45e23f30 963: com.android.inputmethod.latin/10022}
PID # 968: ProcessRecord {45f1ab80 968: com.android.launcher/10010}
PID # 970: ProcessRecord {45e26a20 970: com.android.settings/1000}
PID # 999: ProcessRecord {45e64e20 999: android.process.acore/10005}
PID # 1019: ProcessRecord {45f2d398 1019: com.android.deskclock/10000}
PID # 1029: ProcessRecord {45e15af0 1029: android.process.media/10004}
PID # 1058: ProcessRecord {45fd7ea8 1058: com.android.email/10017}
PID # 1076: ProcessRecord {45fe5548 1076: com.android.bluetooth/10020}
PID # 1087: ProcessRecord {45de2d80 1087: com.android.providers.calendar/10023}
PID # 1101: ProcessRecord {45df5ae8 1101: com.android.quicksearchbox/10015}
PID # 1109: ProcessRecord {45ebfa58 1109: com.android.music/10024}
PID # 1116: ProcessRecord {45ef5280 1116: com.android.protips/10025}
Time since processes crashed:
Process com.KT.NDKOpenGL_AppSwitch uid 10046: last crashed 1112183 ms ago
mHomeProcess: ProcessRecord {45f1ab80 968: com.android.launcher/10010}
mConfiguration: {scale = 1.0 imsi = 0/0 loc = md_US touch = 3 keys = 2/1/2 nav = 3/1 orien = 2 layout = 35 uiMode = 17 seq = 2}
mConfigWillChange: false
mSleeping = false mShuttingDown = false
#
Reply:
Reply:
How to make an Android application not be killed? (Finishing)
http://blog.sina.com.cn/s/blog_3e3fcadd0100yjo2.html
Reply:
Thank landlord to share with you. Slowly research.
Reply:
Reply:
The landlord, how to achieve the user manually after killing service, so service continues to run, to achieve the appropriate logic code
Reply:
Thank you for sharing the landlord may be why I can not find oom_adj in dumpsys activity command? Look priority-less process?
Reply:
I want to phone the process stops, the president of the changed false, which burned after the machine to display the "Address Book Service Stop", the process also get up. I turn the president into a true, burn the machine, or get up, why?
Reply:
Do not understand the value or the application will be cleared
Reply:
mark to work tomorrow to see
Reply:

Reply:
Good text, must be the top! ! !
No comments:
Post a Comment