Back to project page AndroidPINProtectionExample.
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.
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)); }}); } }