Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 电报api-不';不要用线_Java_Api_Exception_Serialization_Telegram - Fatal编程技术网

Java 电报api-不';不要用线

Java 电报api-不';不要用线,java,api,exception,serialization,telegram,Java,Api,Exception,Serialization,Telegram,我使用电报api库。当我使用以下主要方法运行应用程序时: public static void main(String[] args) throws IOException { Application app = new Application(); app.disableLogging(); app.createApi(); app.login(); app.workLoop(); } 它很好用。

我使用电报api库。当我使用以下主要方法运行应用程序时:

    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)
我使用电报机器人项目的代码。
有什么问题吗?谢谢。

您可能还没有设置TLRequestAuthSignIn的一个字段(见第三行)phoneNumber、phoneCodeHash和/或phoneCode。

当您编写
app.main(null)时,您想做什么?此程序不需要任何参数