2013年2月15日金曜日

AndroidアプリにHTTPGETを使う際、GBA PERMITIONエラー発生

エラー:
02-13 00:21:10.204: I/APACHE HTTP (thCr=1) - NafHttpAuthStrategyDefault(32050): (thUse=1)    The current context is NOT a context of GBA service.
02-13 00:21:10.244: I/APACHE HTTP (thCr=1) - GbaSupportPermissionRequestCheckerImpl(32050): (thUse=1) isCurrentProcessRequestedGba()#finished   result=false
02-13 00:21:10.244: I/APACHE HTTP (thCr=1) - GbaSupportPermissionRequestCheckerImpl(32050): (thUse=1) isCurrentProcessAllowedToUseGba()#started   result=false
02-13 00:21:10.254: I/APACHE HTTP (thCr=1) - NafHttpAuthStrategyDefault(32050): (thUse=1)    The GBA permission wasn't requested for this process.
02-13 00:21:10.264: I/APACHE HTTP (thCr=1) - NafHttpAuthStrategyDefault(32050): (thUse=1) It is impossible to support GBA now (many possible reasons: no Android Context, current client is GBA service, etc.), then it will be just usual HTTP.
02-13 00:21:10.264: I/APACHE HTTP (thCr=1) - NafRequestExecutorWrapperRedirectionHandler(32050): (thUse=1)    It isn't GBA flow, redirection responses are not handled.
02-13 00:21:38.491: W/dalvikvm(32050): threadid=1: thread exiting with uncaught exception (group=0x40c191f8)
02-13 00:21:38.671: E/AndroidRuntime(32050): FATAL EXCEPTION: main
02-13 00:21:38.671: E/AndroidRuntime(32050): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cn.kanmenv/com.cn.kanmenv.MainActivity}: android.os.NetworkOnMainThreadException

対応方法:
onCreateメソッドの一番最初、super.onCreate(savedInstanceState);の上に以下のソースを追加
StrictMode.ThreadPolicy policy = new StrictMode.
ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy); 
 
参照資料: