Notes
Notes - notes.io |
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity {
SharedPreferences preferences;
SharedPreferences.Editor editor;
String mail_string,sifre_string;
Button giris;
EditText kullanıcıadı,sifre;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());//preferences objesi
editor = preferences.edit();
if(preferences.getBoolean("login", false)){
Intent i = new Intent(getApplicationContext(),AnasayfaActivity.class);
startActivity(i);
finish();
}
kullanıcıadı = (EditText)findViewById(R.id.KullanıcıAdı);
sifre = (EditText)findViewById(R.id.Sifre);
giris = (Button) findViewById(R.id.btnGiris);
giris.setOnClickListener(new View.OnClickListener() {//giriş butonu tıklandığı zaman
@Override
public void onClick(View v) {
mail_string = kullanıcıadı.getText().toString();
sifre_string = sifre.getText().toString();
if(mail_string.matches("") || sifre_string.matches("")){//bilgiler eksik ise
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
alertDialog.setTitle("Uyar˝");
alertDialog.setMessage("Eksiksiz Doldurunz!");
alertDialog.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
}
});
alertDialog.show();
}else{//Bilgiler doğru ise
String email = preferences.getString("email", "genc");//preferences objesinden kaydettiğimiz değerleri key leri ile geri alıyoruz
String sifre = preferences.getString("sifre", "123");//preferences objesinden kaydettiğimiz değerleri key leri ile geri alıyoruz
if(email.matches(mail_string) && sifre.matches(sifre_string)){//edittextlerden alınan şifre ve mail değerleri shared preferencesdan alınan değerlerle eşleşiyorsa
//Giriş başarılı ise sharedpreferences login değerini true yapıyoruz.
editor.putBoolean("login", true);
Intent i = new Intent(getApplicationContext(),AnasayfaActivity.class);//Anasayfa aktivity si açılır
startActivity(i);
finish();
}else{//şifre ve mail uyuşmuyorsa hata bastırılır
AlertDialog.Builder alertDialog = new AlertDialog.Builder( MainActivity.this);
alertDialog.setTitle("Hata");
alertDialog.setMessage("Mailiniz veya Şifreniz Uyuşmuyor!");
alertDialog.setPositiveButton("Tamam", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int which) {
}
});
alertDialog.show();
}
}
}
});}}
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team