Adding the uses-sdk fields in Androids manifest file causes crash

前端 未结 2 1006
隐瞒了意图╮
隐瞒了意图╮ 2021-01-23 16:21

For some reason, when adding the uses-sdk fields in Android\'s manifest file causes crash. I\'ve not had this happen before but I can\'t get rid of it now.

The relevant

相关标签:
2条回答
  • 2021-01-23 16:59

    The error is NetworkOnMainThreadException Starting with ICS, you cannot do any network access on main thread. You should probably use AsyncTask where you do network access.

    0 讨论(0)
  • 2021-01-23 17:03

    As @Sameer said, you are doing network calls in the core of your Activity. You should NEVER do that. All the code of your activity run on the main thread : the one that is used for the UI. You should not make any heavy calculation on that thread : it takes resources away from the UI, making it lag. An http call is even worse : as long as you don't have the response the UI is blocked.

    Implement your network calls in an AsyncTask.

    0 讨论(0)
提交回复
热议问题