Android Open Source - AndroidPINProtectionExample Start Activity






From Project

Back to project page AndroidPINProtectionExample.

License

The source code is released under:

GNU General Public License

If you think the Android project AndroidPINProtectionExample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.pinexample.ui;
/* w w  w  .  j  ava 2 s  .com*/
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.example.pinexample.R;

/**
 * A simple Activity class with only one button that calls ChangePin, 
 * or Pin activity, depending on the PIN status.
 *  
 * @author drakuwa
 *
 */
public class StartActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    Button settings = (Button)findViewById(R.id.pinSettings);
    settings.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View arg0) {
        // check if there is an existing pin.
        if(prefs.getString("pin", "").length()>0){
          Intent pin = new Intent(StartActivity.this, PinActivity.class);
          pin.putExtra("whereTo", "settings");
          startActivity(pin);
        } else startActivity(new Intent(StartActivity.this, ChangePinActivity.class));
      }});
  }
}




Java Source Code List

com.example.pinexample.fragments.CreatePinFragment.java
com.example.pinexample.fragments.TermsFragment.java
com.example.pinexample.fragments.WelcomeFragment.java
com.example.pinexample.ui.ChangePinActivity.java
com.example.pinexample.ui.MainFragmentActivity.java
com.example.pinexample.ui.PinActivity.java
com.example.pinexample.ui.StartActivity.java
com.example.pinexample.utilities.Log.java
com.example.pinexample.utilities.NumpadKeyboard.java
com.example.pinexample.utilities.Utilities.java