Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top