1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-30 00:01:19 +00:00

Binder failed - cannot create handler inside thread that has not called looper.prepare (fixes #149) (#150)

Fix Binder failed - cannot create handler inside thread that has not called looper.prepare (fixes #149)
This commit is contained in:
Catfriend1 2018-12-24 09:51:25 +01:00 committed by GitHub
parent 190826e660
commit d917ac5e73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -37,8 +37,8 @@ android {
applicationId "com.github.catfriend1.syncthingandroid" applicationId "com.github.catfriend1.syncthingandroid"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 26 targetSdkVersion 26
versionCode 4182 versionCode 4183
versionName "0.14.54.3" versionName "0.14.54.4"
testApplicationId 'com.github.catfriend1.syncthingandroid.test' testApplicationId 'com.github.catfriend1.syncthingandroid.test'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
playAccountConfig = playAccountConfigs.defaultAccountConfig playAccountConfig = playAccountConfigs.defaultAccountConfig

View file

@ -15,6 +15,8 @@ import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Build; import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.PowerManager; import android.os.PowerManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
@ -49,9 +51,19 @@ public class RunConditionMonitor {
private final SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() { private final SyncStatusObserver mSyncStatusObserver = new SyncStatusObserver() {
@Override @Override
public void onStatusChanged(int which) { public void onStatusChanged(int which) {
/**
* We need a Looper here, see issue https://github.com/Catfriend1/syncthing-android/issues/149
*/
Handler mainLooper = new Handler(Looper.getMainLooper());
Runnable updateShouldRunDecisionRunnable = new Runnable() {
@Override
public void run() {
updateShouldRunDecision(); updateShouldRunDecision();
} }
}; };
mainLooper.post(updateShouldRunDecisionRunnable);
}
};
public interface OnShouldRunChangedListener { public interface OnShouldRunChangedListener {
void onShouldRunDecisionChanged(boolean shouldRun); void onShouldRunDecisionChanged(boolean shouldRun);