Skip to content

Instantly share code, notes, and snippets.

@MustafaFerhan
Created July 30, 2015 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MustafaFerhan/071b1b448765a57808f3 to your computer and use it in GitHub Desktop.
Save MustafaFerhan/071b1b448765a57808f3 to your computer and use it in GitHub Desktop.
Process check
public void storeProcessID(Context context, int processid) {
final SharedPreferences prefs = getPushPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(PROCESS_ID, processid);
editor.apply();
}
public int getStoredProcessID(Context context){
final SharedPreferences prefs = getPushPreferences(context);
int process = prefs.getInt(PROCESS_ID, 0);
return process;
}
public boolean isProcessDead(Context context){
int lastProcessID = getStoredProcessID(context);
//DebugLog.e("lastProcessID:" + lastProcessID);
//kullanıcı uygulamayı ilk kez açmış olduğu için eski kayıt yok
if (lastProcessID == 0){
return false;
}
int currentProcess = android.os.Process.myPid();
//DebugLog.e("currentProcess:" + currentProcess);
return currentProcess == lastProcessID ? false : true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment