Created
July 30, 2015 08:02
-
-
Save MustafaFerhan/071b1b448765a57808f3 to your computer and use it in GitHub Desktop.
Process check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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