Login activity
private void storeLoginInfo(String id, String comp_name, String pincode, String mobile, String email, String contact) { getSharedPreferences("PREFERENCE", MODE_PRIVATE) .edit() .putString("id", id) .putString("comp_name", comp_name) .putString("pincode", pincode) .putString("mobile", mobile) .putString("email", email) .putString("contact", contact) .commit(); Session_data.id=id; Session_data.comp_name = comp_name; Session_data.pincode = pincode; Session_data.mobile = mobile; Session_data.email = email; Session_data.contact = contact; }
Login Checking
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Session_data.id=getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("id", "null"); Session_data.comp_name = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("comp_name", "null"); Session_data.pincode = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("pincode", "null"); Session_data.mobile = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("mobile", "null"); Session_data.email = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("email", "null"); Session_data.contact = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getString("contact", "null"); Log.d("mob >>> "+Session_data.id,"mob"+Session_data.contact); if(Session_data.mobile.equals("null")){ init(); }else { Intent intmap = new Intent(LoginActivity.this, GpsTrackerActivity.class); startActivity(intmap); } initweb(); }Session Datapackage com.veer.myapplication.Utils; import android.content.Context; import android.content.Intent; /** * Created by aabit on 7/20/16. */public class Session_data { public static String id = "null"; public static String comp_name = "null"; public static String pincode = "null"; public static String mobile = "null"; public static String email = "null"; public static String contact = "null"; public Session_data() { } public static void logOutUser(Context context) { context.getSharedPreferences("PREFERENCE", context.MODE_PRIVATE) .edit() .putString("id", id) .putString("comp_name", comp_name) .putString("pincode", pincode) .putString("mobile", mobile) .putString("email", email) .putString("contact", contact) .commit(); Session_data.id = "null"; Session_data.comp_name = "null"; Session_data.pincode = "null"; Session_data.mobile = "null"; Session_data.email = "null"; Session_data.contact = "null"; context.startActivity(new Intent(context, com.veer.myapplication.LoginActivity.class)); } }
No comments:
Post a Comment
Dharamart.blogspot.in