在Android的注销功能 [英] Logout functionality in android

查看:215
本文介绍了在Android的注销功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一种社交网络应用程序。我采取的是注销功能。 在注销按钮,单击它应该导航到登录界面,而是它现在导航到主页screen.I现在用的是下面的$ C $下注销。

 的IntentFilter的IntentFilter =新的IntentFilter();
  intentFilter.addAction(com.package.ACTION_LOGOUT);
  registerReceiver(新BroadcastReceiver的(){
    公共无效的onReceive(上下文的背景下,意图意图){

         的System.out.println(的onReceive注销正在进行);
          意图int​​ent1 =新的意图(getApplicationContext(),Login.class);
                    startActivity(intent1);
                                完();
                }
            },IntentFilter的);
 

解决方案

使用下面的注销。

  yourintent.setflag(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
 

它可以帮助你。

I am making a kind of social networking app. I am implementing log-out functionality in it. On Logout button click it should navigate to login screen but instead it is now navigating to the home page screen.I am using the following code for logout..

  IntentFilter intentFilter = new IntentFilter();
  intentFilter.addAction("com.package.ACTION_LOGOUT");
  registerReceiver(new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {

         System.out.println("onReceive Log out in progress");
          Intent intent1 = new Intent(getApplicationContext(),          Login.class);
                    startActivity(intent1);
                                finish();
                }
            }, intentFilter);

解决方案

use following for Logout.

yourintent.setflag(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK);

It may help you

这篇关于在Android的注销功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆