android.os.NetworkOnMainThreadException on service start on android

前端 未结 4 1259
忘了有多久
忘了有多久 2020-12-11 16:40

after trying my brand new service on android i get this:

i guess is something related to the manifest file and permissions, the service is started after the last act

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-11 16:56

    Create function:

    Thread thread = new Thread(new Runnable(){
        @Override
        public void run() {
           .......
        }
    });
    

    And call it from onStartCommand

    thread.start(); 
    

提交回复
热议问题