2013-12-14 35 views
3

如何在Android應用程序中將註銷按鈕進行驗證,如果我在我的應用程序中使用SocialAuthAdapter與社交媒體共享。代碼如下,我有寫來驗證我的註銷按鈕,但它dosent工作:如何在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(); 


    } 

回答

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(); 
     } 
相關問題