Question

Having some doubts on the importing the strict mode in my login application. If i enable this in my code,

   StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

will the security features in my login weakened? Or I should just use the async task?

Was it helpful?

Solution

Since android version 3.0 there has been some restrictions of using the network related code in the main ui thread as it would cause ANR. Hence by putting the Strict mode thread policy in your code you are violating this restriction and you can use network related code in the main thread, This will not anyways weak your login feature.

OTHER TIPS

According to the documentation, the default policy for StrictMode.ThreadPolicy is LAX "... which doesn't catch anything". So unless something was previously setting a non-default policy, your code shouldn't change anything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top