问题描述:

I use telegram-api library. When I run app with the following main method:

 public static void main(String[] args) throws IOException {

Application app = new Application();

app.disableLogging();

app.createApi();

app.login();

app.workLoop();

}

It works fine. But when I do that:

 //Somewhere else

public void testRun() throws Exception {

System.out.println("run");

Application app = new Application();

app.main(null);

Thread.sleep(10*60*1000);

}

It throws the following Exception:

Exception in thread "Scheduller#988181144" java.lang.NullPointerException

at org.telegram.tl.StreamingUtils.writeTLString(StreamingUtils.java:125)

at org.telegram.api.requests.TLRequestAuthSignIn.serializeBody(Unknown Source)

at org.telegram.tl.TLObject.serialize(TLObject.java:46)

at org.telegram.tl.StreamingUtils.writeTLObject(StreamingUtils.java:192)

at org.telegram.tl.StreamingUtils.writeTLMethod(StreamingUtils.java:203)

at org.telegram.api.requests.TLRequestInvokeWithLayer11.serializeBody(Unknown Source)

at org.telegram.tl.TLObject.serialize(TLObject.java:46)

at org.telegram.tl.TLObject.serialize(TLObject.java:34)

at org.telegram.mtproto.schedule.Scheduller.actualPackages(Scheduller.java:388)

at org.telegram.mtproto.schedule.Scheduller.doSchedule(Scheduller.java:406)

at org.telegram.mtproto.MTProto$SchedullerThread.run(MTProto.java:704)

I use the code from telegram-bot project.

What's the problem? Thanks.

网友答案:

Probably you haven't set one of TLRequestAuthSignIn's fields (see 3rd line) phoneNumber, phoneCodeHash and/or phoneCode.

相关阅读:
Top