標題: android如何讓service不被殺死-提高程序優先級 [打印本頁] 作者: 暗桌之光 時間: 2013-8-14 14:36 標題: android如何讓service不被殺死-提高程序優先級 1.在service中重寫下面的方法,這個方法有三個返回值, START_STICKY是service被kill掉後自動重寫建立
[代碼]java代碼:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}----------------
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
Log.v("TrafficService","startCommand");
// -----------------------------------
// Set the priority of the calling thread, based on Linux priorities:
// -----------------------------------
// Changes the Priority of the calling Thread!
Process.setThreadPriority(12);
// Changes the Priority of passed Thread (first param)
Process.setThreadPriority(Process.myTid(), 12);