Skip to content

Commit

Permalink
Merge pull request #69 from proneon267/patch-1
Browse files Browse the repository at this point in the history
Added support for detecting app focus events.
  • Loading branch information
mhsmith committed Jan 26, 2024
2 parents 652a537 + c3d10b8 commit 3a3786d
Showing 1 changed file with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,38 @@ protected void onResume() {
Log.d(TAG, "onResume() complete");
}

protected void onPause() {
Log.d(TAG, "onPause() start");
super.onPause();
userCode("onPause");
Log.d(TAG, "onPause() complete");
}

protected void onStop() {
Log.d(TAG, "onStop() start");
super.onStop();
userCode("onStop");
Log.d(TAG, "onStop() complete");
}
protected void onDestroy() {
Log.d(TAG, "onDestroy() start");
super.onDestroy();
userCode("onDestroy");
Log.d(TAG, "onDestroy() complete");
}
protected void onRestart() {
Log.d(TAG, "onRestart() start");
super.onRestart();
userCode("onRestart");
Log.d(TAG, "onRestart() complete");
}
public void onTopResumedActivityChanged (boolean isTopResumedActivity){
Log.d(TAG, "onTopResumedActivityChanged() start");
super.onTopResumedActivityChanged(isTopResumedActivity);
userCode("onTopResumedActivityChanged", isTopResumedActivity);
Log.d(TAG, "onTopResumedActivityChanged() complete");
}

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Log.d(TAG, "onActivityResult() start");
Expand Down Expand Up @@ -144,7 +176,12 @@ private PyObject userCode(String methodName, Object... args) {
return null;
}
try {
return pythonApp.callAttr(methodName, args);
if (pythonApp.containsKey(methodName)) {
return pythonApp.callAttr(methodName, args);
} else {
// Handle the case where the method doesn't exist
return null;
}
} catch (PyException e) {
if (e.getMessage().startsWith("NotImplementedError")) {
return null;
Expand Down

0 comments on commit 3a3786d

Please sign in to comment.