此為android 針對網路部份做了更嚴格的限制,要解決此問題,請在oncreate 中加入以下程式

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());

arrow
arrow
    文章標籤
    NetworkOnMainThreadException
    全站熱搜

    狼翔月影 發表在 痞客邦 留言(1) 人氣()