Skip to content

Commit

Permalink
shared pref
Browse files Browse the repository at this point in the history
  • Loading branch information
rishab247 committed Feb 11, 2020
1 parent 5649619 commit 1005533
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ protected String doInBackground(String... voids) {
sharedpreferences = scontext.getSharedPreferences("Login", Context.MODE_PRIVATE);
editor = sharedpreferences.edit();
if(sharedpreferences.getLong("Exp_time", 0)<System.currentTimeMillis())
{
editor.clear();
Toast.makeText(scontext,"You are Loggesd out",Toast.LENGTH_SHORT).show();



}
String token= sharedpreferences.getString("Token", "");
url = url + token;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void onPreExecute() {
Context scontext = contextRef.get();
sharedpreferences = scontext.getSharedPreferences("Login", Context.MODE_PRIVATE);
editor = sharedpreferences.edit();
dialog = new ProgressDialog(scontext);
dialog = new ProgressDialog(scontext);
dialog.setMessage("Please wait...");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/java/com/cu/project/ui/Profiile/ProfileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
Expand All @@ -26,6 +27,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
Expand Down Expand Up @@ -235,5 +237,22 @@ public void processVerifyFinish(String[] output) {
Log.e( "processVerifyFinish: ",sharedpreferences.getString("p_no","") );

}

@Override
public void onBackPressed() {
new AlertDialog.Builder(this)
.setTitle("Exit")
.setMessage("Do you want to Exit?")
.setPositiveButton( "Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1); }
})

.setNegativeButton("No", null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ public void processFinish(Object output) {
intent_name.putExtra("dob_" , dobdate);
startActivity(intent_name);
}

}

0 comments on commit 1005533

Please sign in to comment.