【发布时间】:2014-11-21 02:58:26
【问题描述】:
当用户用户从当前运行的应用程序列表中删除应用程序时,我想清除用户凭据并注销用户。在这里,我正在做的是,当用户通过刷掉应用程序列表来结束应用程序时,其中的应用程序应该执行注销。但是当用户通过滑动删除应用程序时,它什么也不做。下面是我的代码。
public class MyService extends Service{
public void onTaskRemoved(){
Log.i("RootActivity:onTaskRemoved()","******TaskRemoved******");
SharedPreferences pref = getSharedPreferences(getString(R.string.pref_current_user), MODE_PRIVATE);
SharedPreferences.Editor editor = pref.edit();
editor.clear(); // CLEAR ALL FILEDS
editor.commit(); // COMMIT CHANGES
Log.i("RootActivity:onTaskRemoved()","******APP LOGGEDOUT******");
setloginButton(); // Change logout button to login
Log.i("RootActivity:onTaskRemoved()","******loginButton is set******");
}
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
}
【问题讨论】:
-
你的方法
onTaskRemoved()被调用了吗? -
@VedPrakash nupp,它没有登录logcat
标签: android android-service swipe logout