3

如果我在我的应用程序中使用 SocialAuthAdapter 与社交媒体共享,如何在 android 应用程序中的注销按钮上进行验证。代码如下,我编写了它来验证我的注销按钮,但它不起作用:

public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
    case R.id.back:
        Route_stops.this.finish();
        break;
    case R.id.update:

        edit = (EditText) findViewById(R.id.editTxt);
        String msg=edit.getText().toString();

        Log.v("update1", "update1"+msg);
        if(msg.equals(""))
        {
            Toast.makeText(Route_stops.this, "You have to write something for updation", 100).show();
        }
        break;
    case R.id.logoutbutton:
        /*Intent logout  = new Intent(Route_stops.this,Logout.class);
        startActivity(logout);*/
        if(adapter==null)
        {

            Toast.makeText(Route_stops.this, "You have to sign in first", 100).show();
        }
        else{
            try{
                /*CookieSyncManager.createInstance(this); 
                CookieManager cookieManager = CookieManager.getInstance();
                cookieManager.removeAllCookie();*/
            adapter.signOut(Route_stops.this,Provider.FACEBOOK.toString());
            adapter.signOut(Route_stops.this,Provider.TWITTER.toString());
            adapter.signOut(Route_stops.this,Provider.LINKEDIN.toString());
            adapter.signOut(Route_stops.this,Provider.MYSPACE.toString());
            if(Provider.FACEBOOK==null && Provider.TWITTER==null && Provider.LINKEDIN==null && Provider.MYSPACE==null)
                Toast.makeText(Route_stops.this, "You have Logged In First in any Social media", Toast.LENGTH_LONG).show();
            else
                Toast.makeText(Route_stops.this, "You have Logged Out", Toast.LENGTH_LONG).show();
            }
            catch(Exception E)
            {
                System.out.println(E.toString());
            }
        }

        break;
    case R.id.option:
        Toast.makeText(Route_stops.this, "Map", 100).show();


    }
4

1 回答 1

0

改变这个:

if(Provider.FACEBOOK.isEmpty() && Provider.TWITTER.isEmpty() && Provider.LINKEDIN.isEmpty() && Provider.MYSPACE.isEmpty())
            Toast.makeText(Route_stops.this, "You have Logged In First in any Social media", Toast.LENGTH_LONG).show();
        else
            Toast.makeText(Route_stops.this, "You have Logged Out",  Toast.LENGTH_LONG).show();
        }

或者

 if(Provider.FACEBOOK.equals("") && Provider.TWITTER.equals("") && Provider.LINKEDIN.equals("") && Provider.MYSPACE.equals(""))
            Toast.makeText(Route_stops.this, "You have Logged In First in any Social media", Toast.LENGTH_LONG).show();
        else
            Toast.makeText(Route_stops.this, "You have Logged Out",  Toast.LENGTH_LONG).show();
        }
于 2013-12-14T10:40:37.357 回答