mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-12 08:47:50 +01:00
fix to contact relay in foreground on Oreo+
Background still needs a lot of work.
This commit is contained in:
parent
b23b837009
commit
0a0107dd7f
2 changed files with 28 additions and 1 deletions
|
@ -192,7 +192,32 @@ public class RelayService extends XWService
|
|||
|
||||
private static boolean inForeground()
|
||||
{
|
||||
return sInForeground != null && sInForeground;
|
||||
boolean result = sInForeground != null && sInForeground;
|
||||
Log.d( TAG, "inForeground() => %b", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void onAppStateChange( Context context, boolean inForeground )
|
||||
{
|
||||
Log.d( TAG, "onAppStateChange(inForeground=%b)", inForeground );
|
||||
if ( null == sInForeground || inForeground() != inForeground ) {
|
||||
sInForeground = inForeground;
|
||||
// Intent intent =
|
||||
// getIntentTo( context,
|
||||
// inForeground ? BTAction.START_FOREGROUND
|
||||
// : BTAction.START_BACKGROUND );
|
||||
// startService( context, intent );
|
||||
}
|
||||
}
|
||||
|
||||
static void onAppToForeground( Context context )
|
||||
{
|
||||
onAppStateChange( context, true );
|
||||
}
|
||||
|
||||
static void onAppToBackground( Context context )
|
||||
{
|
||||
onAppStateChange( context, false );
|
||||
}
|
||||
|
||||
public static void startService( Context context )
|
||||
|
|
|
@ -106,9 +106,11 @@ public class XWApp extends Application implements LifecycleObserver {
|
|||
switch( event ) {
|
||||
case ON_RESUME:
|
||||
BTService.onAppToForeground( this );
|
||||
RelayService.onAppToForeground( this );
|
||||
break;
|
||||
case ON_STOP:
|
||||
BTService.onAppToBackground( this );
|
||||
RelayService.onAppToBackground( this );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue