Android Studio - Complete Android Apps Tutorial – Account Manager - Day 23 - 9.02
Account Manager
2
Account Manager A Centralized repository for storing user credentials Permissions in Android Manifest “android.permission.GET_ACCOUNTS” Access the list of accounts “android.permission.ACCOUNT_MANAGER” Manage OAuth2 authentication “android.permission.USE_CREDENTIALS” Request an Auth Token
3
Accounts in Settings
4
AccountManager is obtained with AccountManager am = AccountManager.getMainActivity.this; A list of accounts is obtained with Account[] accounts = am.getAccounts; forAccount account:accounts String name = account.name; String type = account.type;
5
Account Type examples Google: com.google Dropbox: com.dropbox.android.account Facebook: com.facebook.auth.login Twitter: com.twitter.android.auth.login Yahoo: com.yahoo.mobile.client.share.account LinkedIn: com.linkedin.android Outlook: com.outlook.Z7.eas GitHub: com.github
6
Request an Auth Token final AccountManager am = AccountManager.getthis; Call getAuthToken in another Thread or AsyncTask The 2nd parameter is the authTokenType and cl is for Calendar Data API am.getAuthTokenaccount, "cl", null, MainActivity.this, callback, null;
7
Request an Auth Token
AccountManagerCallbackBundle callback = new AccountManagerCallbackBundle @Override public void runAccountManagerFutureBundle future // obtain the token in the run method
8
Request an Auth Token // obtain the token in the run method Bundle bundle = future.getResult; if bundle.containsKey AccountManager.KEY_AUTHTOKEN String authToken = future.getResult .getStringAccountManager.KEY_AUTHTOKEN;
9
Request an Auth Token
10
Device Policy Manager
11
Device Administration API Allow an App to control the security level of the device Allow an App to detect security issues such as multiple failed password attempts Allow an App to run utilities that are extremely useful when the device is compromised Lock the device Reset the password Wipe the device Allow an App to disable cameras
12
Device Administrators metadata XML resource ?xml version="1.0" encoding="utf-8"? device-admin xmlns:android="http://schemas.android.com/apk/res/andr oid" uses-policies force-lock / /uses-policies /device-admin
13
Device Administrators uses-policies disable-camera / - disable the cameras encrypted-storage / - ask the user to encrypt the device storage expire-password / - set an expiration time of password force-lock / - lock the device limit-password / - set criteria for password quality reset-password / - reset the password watch-login / - monitor login attempts wipe-data / - wipe the device
14
DeviceAdminReceiver Subclass of DeviceAdminReceiver is required to exist as a Application component No method is required to be overridden Methods that can be overridden onPasswordFailedContext, Intent onPasswordExpiringContext, Intent
15
DeviceAdminReceiver subclass in Android Manifest receiver android:name="AdminReceiver" android:permission= "android.permission.BIND_DEVICE_ADMIN" meta-data android:name="android.app.device_admin" android:resource="@xml/device_admin" / intent-filter action android:name= "android.app.action.DEVICE_ADMIN_ENABLED" / /intent-filter /receiver
16
DeviceAdminReceiver subclass in Android Manifest Only Apps hold the BIND_DEVICE_ADMIN permission can send the broadcast which are only signed with firmware's signing key. meta-data resource point to the device_admin.xml Listen to “android.app.action.DEVICE_ADMIN_ENABLED” to notify failed logins or other events
17
Implementation of Device Administration in Activity cn is the Component Name of the subclass of the DeviceAdminReceiver mgr is the DevicePolicyManager cn = new ComponentNamethis, AdminReceiver.class; mgr = DevicePolicyManagergetSystemService Context.DEVICE_POLICY_SERVICE;
18
Enable Device Administration if!mgr.isAdminActivecn Intent i = new IntentDevicePolicyManager. ACTION_ADD_DEVICE_ADMIN; i.putExtraDevicePolicyManager. EXTRA_DEVICE_ADMIN, cn; i.putExtraDevicePolicyManager. EXTRA_ADD_EXPLANATION, "Testing Remote Lock"; startActivityi;
19
Enable Device Administration
20
Lock the phone similar to pressing the power button if Device Administration is enabled
ifmgr.isAdminActivecn mgr.lockNow;
21
Check Device Administration in Settings → Security → Device administrators
22
Download Manager
23
DownloadManager Handles long-running HTTP downloads Introduced in Android 2.3 API Level 9 Requires the permission “android.permission.INTERNET” “android.permission.WRITE_EXTERNAL_STORAGE” Handles retrying after failures or across connectivity changes between WiFi and 3G
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Android Studio - Complete Android Apps Tutorial – Account Manager - Day 23 - 9.02», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.