Back to project page on-the-hook.
The source code is released under:
MIT License
If you think the Android project on-the-hook listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.yoandinkov.onthehook; //w w w . j ava2 s . co m import com.yoandinkov.onthehook.models.HttpResponseWrapper; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.content.Intent; import android.content.SharedPreferences; public class MainMenuActivity extends RequestActivity{ private Button ButtonStartFishing; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_menu); this.setButtonStartFishing((Button)findViewById(R.id.mainMenuButtonStartFishing)); this.getButtonStartFishing().setOnClickListener(this); String sessionKey = ""; if(getIntent().getExtras() != null) { sessionKey = getIntent().getExtras().getString("sessionKey"); } if (sessionKey != null) { this.setSessionKey(sessionKey); this.setCredentials(sessionKey); } } private void setCredentials(String sessionKey) { SharedPreferences credentials = getSharedPreferences("credentials", MODE_PRIVATE); SharedPreferences.Editor credentialsEditor = credentials.edit(); credentialsEditor.putString("sessionKey", sessionKey); credentialsEditor.commit(); } private String getCredentials() { String result = ""; SharedPreferences credentials = getSharedPreferences("credentials", MODE_PRIVATE); result = credentials.getString("sessionKey", null); return result; } @Override public void onClick(View clickedView) { int clickedViewId = clickedView.getId(); switch(clickedViewId) { case R.id.mainMenuButtonStartFishing: this.startFishingActivity(clickedView); break; } } private void startFishingActivity(View currentView) { Intent startFishingIntent = new Intent(this, FishingActivity.class); if (getIntent().getExtras() != null) { startFishingIntent.putExtra("sessionKey", getIntent().getExtras().getString("sessionKey")); } else { startFishingIntent.putExtra("sessionKey", this.getCredentials()); } startActivity(startFishingIntent); } public Button getButtonStartFishing() { return ButtonStartFishing; } public void setButtonStartFishing(Button buttonStartFishing) { ButtonStartFishing = buttonStartFishing; } @Override protected void handleResponse(HttpResponseWrapper response) { } }