Skip to content

Commit 63b2882

Browse files
committed
Add logging to debug problems with the Android app
* Add logging for activity lifecycle handlers * Log the return code of the Qt event loop This is a bit excessive and should probably be revereted later. For the time being it is helpful, though.
1 parent cfe22a3 commit 63b2882

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

tray/android/src/io/github/martchus/syncthingtray/Activity.java

+29
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.view.HapticFeedbackConstants;
1111
import android.view.View;
1212
import android.widget.Toast;
13+
import android.util.Log;
1314

1415
import androidx.core.content.FileProvider;
1516

@@ -21,6 +22,7 @@
2122
import io.github.martchus.syncthingtray.Util;
2223

2324
public class Activity extends QtActivity {
25+
private static final String TAG = "SyncthingActivity";
2426

2527
public boolean performHapticFeedback() {
2628
View rootView = getWindow().getDecorView().getRootView();
@@ -109,11 +111,13 @@ public void stopSyncthingService() {
109111
void handleSendText(Intent intent) {
110112
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
111113
if (sharedText != null) {
114+
Log.i(TAG, "Sending shared text to Qt Quick app");
112115
sendAndroidIntentToQtQuickApp("sharedtext:" + sharedText, false);
113116
}
114117
}
115118

116119
public void onCreate (Bundle savedInstanceState) {
120+
Log.i(TAG, "Creating");
117121
super.onCreate(savedInstanceState);
118122
Intent intent = getIntent();
119123
String action = intent.getAction();
@@ -123,6 +127,31 @@ public void onCreate (Bundle savedInstanceState) {
123127
}
124128
}
125129

130+
public void onStart() {
131+
Log.i(TAG, "Starting");
132+
super.onStart();
133+
}
134+
135+
public void onResume() {
136+
Log.i(TAG, "Resuming");
137+
super.onResume();
138+
}
139+
140+
public void onPause() {
141+
Log.i(TAG, "Pausing");
142+
super.onPause();
143+
}
144+
145+
public void onStop() {
146+
Log.i(TAG, "Stopping");
147+
super.onStop();
148+
}
149+
150+
public void onDestroy() {
151+
Log.i(TAG, "Destroying");
152+
super.onDestroy();
153+
}
154+
126155
protected void onNewIntent(Intent intent) {
127156
boolean fromNotification = intent.getBooleanExtra("notification", false);
128157
if (fromNotification) {

tray/application/main.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ static int runApplication(int argc, const char *const *argv)
312312
quickApp.applySettings();
313313
QObject::connect(&app, &QCoreApplication::aboutToQuit, &quickApp, &App::shutdown);
314314
SyncthingLauncher::setMainInstance(quickApp.launcher());
315-
return app.exec();
315+
const auto res = app.exec();
316+
#if defined(Q_OS_ANDROID)
317+
qDebug() << "Qt event loop exited with return code " << res;
318+
#endif
319+
return res;
316320
}
317321
#endif
318322

0 commit comments

Comments
 (0)