telegram api - 不使用线程

时间:2015-02-15 05:00:40

标签: java api exception serialization telegram

我使用telegram-api库。当我使用以下主要方法运行app时:

    public static void main(String[] args) throws IOException {
        Application app = new Application();
        app.disableLogging();
        app.createApi();
        app.login();
        app.workLoop();
    }

工作正常。但是当我这样做时:

    //Somewhere else
    public void testRun() throws Exception {
        System.out.println("run");
        Application app = new Application();
        app.main(null);
        Thread.sleep(10*60*1000);
    }

它抛出以下异常:

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)

我使用来自telegram-bot项目的代码。 问题是什么?感谢。

1 个答案:

答案 0 :(得分:0)

可能您还没有设置TLRequestAuthSignIn的一个字段(请参阅第3行)phoneNumber,phoneCodeHash和/或phoneCode。