public int onStartCommand (Intent intent, int flags, int startId) {
while (1> 0) {
try {
Thread.sleep (4000);
Log.i ("log", "onstart");
} Catch (InterruptedException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
return super.onStartCommand (intent, flags, startId);
}
Will I want to run a background servie a value that I wrote this in this method in this but his error. . . Said return super.onStartCommand (intent, flags, startId);
Code has not run, I like to ask me how to run this program consistent with the purpose of it<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The landlord is the meaning. . . ?
public int onStartCommand (Intent intent, int flags, int startId) {
if (true) {/ / add this, can be compiled. . .
while (1> 0) {
try {
Thread.sleep (4000);
Log.i ("log", "onstart");
} Catch (InterruptedException e) {
e.printStackTrace ();
}
}
}
return super.onStartCommand (intent, flags, startId);
}
Reply:
The main thread callback must return within 5 seconds, and the other to build a thread to handle this stuff.
Also on Android sleep seemingly unreliable, starting a long-running afraid Alarm
Reply:
Is this meant. . . What is the problem you
Do you want a new thread? How to use the new thread Yeah my little vain
Reply:
service operation not do overtime. . . You can do this with a timer. timer and timertask
Reply:
Beauty, put your mail to me, I put the project demo to you.
Reply:
My demo is BroadcastReceiver + Service, without power management, but the implementation is still running when the lock screen function, if power management is prohibited lock screen, then run your project a half-day phone no electricity
Reply:
seeking demo, thank zxc---kfc@sohu.com
Reply:
Your e-mail address is: zxc---kfc@sohu.com?
Reply:
Is to open a thread to do. service can not be directly put in while (true)
Reply:
Has been sent to the mailbox, please check
Reply:
The landlord can also send me a copy of you. fengyun-shen@163.com
Reply:
Landlord, demo can give me a copy, I also encountered the same problem, I want a Service has been running in the background. My mail: 1254877260@qq.com
Reply:
The landlord can give me a copy? The problem I have worried for a long time, the mailbox 454850015@qq.com, thank you!
No comments:
Post a Comment