如何在Android应用中进行验证

时间:2013-12-14 10:17:18

标签: android socialauth

我如何在Android应用中的注销按钮上进行验证,如果我在我的应用中使用SocialAuthAdapter与社交媒体共享。我编写的代码如下所示,以验证我的注销按钮,但它有效:

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();


    }

1 个答案:

答案 0 :(得分: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();
        }

OR

 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();
        }