2017-03-08 1 views
2

계정을 관리하기 위해 Android 계정 관리자를 사용하고 있습니다.Android 계정 관리자, 사용자가 '계정 및 동기화'메뉴에서 계정을 삭제할 때 콜백이 있습니까?

아시다시피 '계정 & 동기화'메뉴에서 계정을 삭제할 수 있습니다.

사용자가 수행 할 때 콜백이 있습니까? (앱이 실행 중이 아님)

사용자가 로그 아웃 할 때 무언가 (예 : 서버에 토큰을 보내지 말고 클린 DB)를하고 싶습니다.

답변

0

사용하십시오 BroadcastReceiver :

public class MyBroadcastReceiver extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
     final String action = intent.getAction(); 

     // start the SimlessMainService and set an Action Tag 
     Intent yourServiceToHandleThisIntent = new Intent(context, YourServiceToHandleThis.class); 
     if (android.accounts.AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(action)) { 
      yourServiceToHandleThisIntent .setAction(Constants.ACTION_LOGIN_ACCOUNTS_CHANGED); 
     } 
     context.startService(yourServiceToHandleThisIntent); 
    } 
} 

그리고 Manifest.xml의 :

<application> 
... 
    <receiver 
      android:name=".MyBroadcastReceiver " 
      android:enabled="true"> 
      <intent-filter> 
       <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" /> 
      </intent-filter> 
     </receiver> 
... 
</application>