java - android注解@background NetworkOnMainThreadException

标签 java android android-annotations networkonmainthread

为什么会出现这个错误? android 注释不应该处理线程吗?任何帮助将不胜感激 :)。谢谢

@EActivity(R.layout.activity_main)
public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        tradingHistory();

    }
    void myMethod() {
        tradingHistory();
    }
    @Background
    void tradingHistory (){
        Helper helper = new Helper();
        try {

            helper.TradeHistory tradeHistory = helper.getTradeHistory();
            System.out.println(tradeHistory.toString());
        } catch (Helper.HelperException e) {
            e.printStackTrace();
        }
    }



}

最佳答案

您可能在 list 中使用了错误的 Activity - 您应该使用 MainActivity_ 而不是 MainActivity

关于java - android注解@background NetworkOnMainThreadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28862525/

相关文章:

java - Tomcat提交异常数量的虚拟内存并且不释放它

java - 在分布式服务架构中使用 System.currentTime?

android - Cygdrive 终端错误 : opus/src/opus. o 失败

android - AndroidAnnotations 的继承 Activity

androidannotations 4.0.0 不显示布局

java - 为什么 Intellij-IDEA 会忽略我的 tomcat/conf/server.xml 上下文标记?

java - Spring Boot 应用程序无法以类路径 : [] 启动

java - AndroidAnnotation REST 处理回调

java - 从android中的数组列表中逐一使用项目

java - 我的 XML 文件不显示任何内容