2014-01-14 54 views
0

我面臨間歇性應用程序流問題。 在這裏,我有一個登錄屏幕,我可以第一次登錄。但是當我註銷和/或重新登錄時,我無法進一步遍歷。作爲解決方法,我需要卸載我的應用程序並重新安裝,並且流程正常。Android:Intermitent應用程序流問題

任何人都可以請指導我在可能的問題。

LoginActivity.java

 GetWebServiceManager passwordExpiryWSManager = new GetWebServiceManager(); 

     //to check network connectivity (data connection/Wi-Fi) 
     ConnectivityManager connectionManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); 
     NetworkInfo networkInformation = connectionManager.getActiveNetworkInfo(); 

     if (networkInformation != null && networkInformation.isConnected() == true) { 
      try { 
//    passwordExpiryString = passwordExpiryWSManager.execute("http://172.25.164.143:8088/api/Login/GetExpiredPassword/?lContactKey=" + username.getText().toString()).get(); 
       passwordExpiryString = passwordExpiryWSManager.execute(AppConstants.URL + "/Login/GetExpiredPassword/?lContactKey=" + username.getText().toString()).get(); 

       jsonObjectPassExpiry = new JSONObject(passwordExpiryString); 
       jsonArrayPassExpiry = jsonObjectPassExpiry.getJSONArray("LstLoginDetail"); 
      } catch (InterruptedException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (ExecutionException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } catch (JSONException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
      } 

      /* 
      * Converting JSON string response from Webservice into Java Object 
      * */ 
      if (jsonArrayPassExpiry != null) { 
       Gson gson = new Gson(); 
       LoginTO[] loginExpTO = gson.fromJson(jsonArrayPassExpiry.toString(), LoginTO[].class); 
       loginListPassExpiry = Arrays.asList(loginExpTO); 
       intent = getIntent(); 

       if (loginListPassExpiry.get(0).getlSuccess() == 1) { 
        intent.setClass(getApplicationContext(), PortfolioSummaryFragmentActivity.class); 
//     intent.putExtra("sToken", loginList.get(0).getsToken()); 
        startActivity(intent); 
       } else { 
        intent.setClass(getApplicationContext(), PasswordExpiryActivity.class); 
//     intent.putExtra("sToken", loginList.get(0).getsToken()); 
        startActivity(intent); 
       } 
      } else { 
       Toast.makeText(getApplicationContext(), "Service is not responding. Please try again later!!", Toast.LENGTH_SHORT).show(); 
      } 
     } else { 
      Toast.makeText(getApplicationContext(), "Network connection unavailable. Please check your data plan or Wi-Fi connection!!", Toast.LENGTH_SHORT).show(); 
     } 

Logout.java

public class LogoutActivity extends Activity { 
    private TextView successResponse; 
    private Intent intent; 
    private Button btnLLogin; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.logout_success); 

     successResponse = (TextView) findViewById(R.id.txtvwLSuccessMessage); 
     btnLLogin = (Button) findViewById(R.id.btnLLogin); 

     intent = getIntent(); 
     successResponse.setText(intent.getStringExtra("successResponse")); 
    } 

    public void Login(View v) { 
     btnLLogin.setTextColor(getResources().getColor(R.color.black)); 
     intent = new Intent(this, LoginActivity.class); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     startActivity(intent); 
    } 

    @Override 
    public void onBackPressed() { 
     finish(); 
    } 
} 
+0

您能解釋「我無法進一步遍歷」嗎?您的意思是說startActivity()方法不會執行......或者他們做但不工作。你也需要自由地添加一些Log.d(「我在這裏XXX」);語句來幫助您調試這些情況。 – robnick

+0

你在哪裏打電話登錄(查看v)在你的代碼? –

+0

請做一些家庭工作與http://www.peachpit.com/articles/article.aspx?p=1874864 –

回答

1

請使用intent = new Intent(LogoutActivity.this, LoginActivity.class);代替intent = new Intent(this, LoginActivity.class);

這種使用 最重要的旁邊 添加android:launchMode="singleTask "您的清單中的活動元素活動LoginActivity

+0

對不起,有問題,但請你解釋爲什麼我會需要使用這個 'intent = new Intent(LogoutActivity.this,LoginActivity.class);' – VikramV

+0

使用當前上下文和LogoutActivity總是更好。這是很好用,這個引用即將使用當前運行的對象。所以不要打擾它..但嘗試使用android:launchMode =「singleTask」 –

+0

我已經有我的清單文件中的android:launchMode =「singleTask」'。而且,當我重新打開登錄屏幕時,我已經獲得了之前使用過的預填充值。這是我的間歇性問題的根源嗎? – VikramV