Tôi đã tạo Authenticator, tôi đã xây dựng một SyncAdapter (cả hai có thể được thực hiện thủ công thông qua các cài đặt trên trình mô phỏng).Trình xác thực khởi chạy Android Authenticator Màn hình đăng nhập khi không có tài khoản hiện tại
Làm cách nào để ứng dụng của tôi khởi chạy màn hình đăng nhập (phương thức addAccount) khi ứng dụng khởi chạy, nếu không tìm thấy tài khoản nào?
Đây là manifest.xml của tôi ...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lateral.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permission android:name="android.permission.USE_CREDENTIALS"/>
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".myappApplication">
<activity android:name=".ui.EventListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name=".authenticator.AccountAuthenticatorService" android:exported="true" android:process=":auth">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
<meta-data android:name="android.accounts.AccountAuthenticator" android:resource="@xml/authenticator"/>
</service>
<service android:name="sync.EventsSyncAdapterService" android:exported="true" android:process=":events">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data android:name="android.content.SyncAdapter" android:resource="@xml/sync_events" />
</service>
<activity android:excludeFromRecents="true" android:name=".authenticator.myappAuthenticatorActivity">
<!--
No intent-filter here! This activity is only ever launched by
someone who explicitly knows the class name
-->
</activity>
</application>
</manifest>
sẽ đi đâu? – Rabbott
Trong ứng dụng của bạn :) Gọi nó từ 'onResume()' để xử lý trường hợp khi người dùng xóa tài khoản và sau đó quay trở lại ứng dụng của bạn. –
Hoàn hảo - như đã đề cập bởi @ zed-scio làm cách nào để ngăn ý định khác hiển thị trước khi màn hình đăng nhập hiển thị .. tại thời điểm này, phương thức onResume chỉ bao gồm mã của bạn và 'super.onResume();' nhưng mục đích được thiết lập để hiển thị như mặc định nhấp nháy – Rabbott