我的代码有错误。请帮忙
代码
public void toCallAsynchronous() {
Log.d(Tag, "проверка toCallAsynchronous");
final Handler handler = new Handler();
Timer timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
try {
// TODO: handle exception
//AutoPretraga zadatak = new AutoPretraga();
//zadatak.execute();
startService(
new Intent(ctx, ServiceUpdate.class));
Log.d(Tag, "ГУГЛ вперед!!!!!!!!");
//googleConnect();
} catch (Exception e) {
Log.d(Tag, e.getMessage());
}
}
});
}
};
timer.schedule(doAsynchronousTask, 0, 60000); // execute in every 2 second
}
日志
05-30 12:12:04.984: E/AndroidRuntime(9545): FATAL EXCEPTION: main
05-30 12:12:04.984: E/AndroidRuntime(9545): java.lang.NullPointerException: println needs a message
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.util.Log.println_native(Native Method)
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.util.Log.d(Log.java:154)
05-30 12:12:04.984: E/AndroidRuntime(9545): at com.example.ok1.CopyOfMainActivity$1$1.run(CopyOfMainActivity.java:514)
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.os.Handler.handleCallback(Handler.java:587)
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.os.Handler.dispatchMessage(Handler.java:92)
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.os.Looper.loop(Looper.java:130)
05-30 12:12:04.984: E/AndroidRuntime(9545): at android.app.ActivityThread.main(ActivityThread.java:3687)
05-30 12:12:04.984: E/AndroidRuntime(9545): at java.lang.reflect.Method.invokeNative(Native Method)
05-30 12:12:04.984: E/AndroidRuntime(9545): at java.lang.reflect.Method.invoke(Method.java:507)
05-30 12:12:04.984: E/AndroidRuntime(9545): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-30 12:12:04.984: E/AndroidRuntime(9545): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-30 12:12:04.984: E/AndroidRuntime(9545): at dalvik.system.NativeStart.main(Native Method)