I’m making login application for Android
i’m stucked at the user’s login status
if the user has logged in, the login activity will not displayed and the application will proceed to main activity
this is for saving logged in user data, such as username, id, coordinates, etc
loginVars.java
package com.nigmagrid.go;
import android.app.Application;
public class loginVars extends Application{
private static String npp;
private static String nama;
private static String id;
private static String lokasi_tugas;
private static String koordinat;
@Override
public void onCreate() {
super.onCreate();
npp = "";
nama = "";
id = "";
lokasi_tugas = "";
koordinat = "";
}
public static String getNPP() {
return npp;
}
public static void setNPP(String npp) {
loginVars.npp = npp;
}
public static String getNama() {
return nama;
}
public static void setNama(String nama) {
loginVars.nama = nama;
}
public static String getId() {
return id;
}
public static void setId(String id) {
loginVars.id = id;
}
public static String getLokasiTugas() {
return lokasi_tugas;
}
public static void setLokasiTugas(String lokasi_tugas) {
loginVars.lokasi_tugas = lokasi_tugas;
}
public static String getKoordinat() {
return koordinat;
}
public static void setKoordinat(String koordinat) {
loginVars.koordinat = koordinat;
}
}
and this is my login status checker
public boolean Logged(){
String npp = loginVars.getNPP().toString();
String nama = loginVars.getNama().toString();
String id = loginVars.getId().toString();
//String koordinat = vars.getKoordinat().toString();
if(npp.equals("") || nama.equals("") || id.equals("")){
return false;
}else{
return true;
}
}
and this is where i placed the checker on my login.java
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if(Logged()){
Intent gotoApp = new Intent(getApplicationContext(), inputBarcode.class);
startActivity(gotoApp);
}
//scripts for login
the login checker wont work, and the application stopped
how do i fix this?
or you maybe have a solution how to make login checker?
thanks
Here is a workaround. You can save the user info in any
UserInfo.txtwhile logging in the user.then you can check the file
If the file exists, it indicates the User is logged in, you can proceed to the
InputBarcode.class. Else the User have to logged in.while doing logout, Just delete the file.
and the file will be deleted.