Android: Хранение имени пользователя и пароля?

Если я хочу сохранить имя пользователя и пароль, который будет использоваться в приложении Android, что лучший способ состоит в том, чтобы сделать это? Это через предпочтительный экран (но что, если пользователь пропускает это?), или всплывающее окно диалоговое окно и просят у пользователя учетные данные? Если так, я действительно должен поддержать состояние для приложения. Как я сделал бы это?

174
задан Legend 18 December 2009 в 00:11
поделиться

2 ответа

Most Android and iPhone apps I have seen use an initial screen or dialog box to ask for credentials. I think it is cumbersome for the user to have to re-enter their name/password often, so storing that info makes sense from a usability perspective.

The advice from the (Android dev guide) is:

In general, we recommend minimizing the frequency of asking for user credentials -- to make phishing attacks more conspicuous, and less likely to be successful. Instead use an authorization token and refresh it.

Where possible, username and password should not be stored on the device. Instead, perform initial authentication using the username and password supplied by the user, and then use a short-lived, service-specific authorization token.

Using the AccountManger is the best option for storing credentials. The SampleSyncAdapter provides an example of how to use it.

If this is not an option to you for some reason, you can fall back to persisting credentials using the Preferences mechanism. Other applications won't be able to access your preferences, so the user's information is not easily exposed.

113
ответ дан 23 November 2019 в 20:32
поделиться

Вы также можете посмотреть пример SampleSyncAdapter из SDK. Это может вам помочь.

2
ответ дан 23 November 2019 в 20:32
поделиться
Другие вопросы по тегам:

Похожие вопросы: