Kiosk goes to main menu after 60s no face found during game

This commit is contained in:
Ruben 2017-03-29 19:38:19 +02:00
parent 90c898db82
commit 8dc463c388
3 changed files with 24 additions and 7 deletions

View file

@ -9,8 +9,8 @@ android {
applicationId 'com.rubenvandeven.emotion_hero.kiosk'
minSdkVersion 16
targetSdkVersion 24
versionCode 7
versionName '0.9'
versionCode 8
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 16

View file

@ -28,11 +28,6 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@style/FullscreenTheme">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".IntroActivity"

View file

@ -35,6 +35,8 @@ import com.affectiva.android.affdex.sdk.detector.Face;
import java.util.HashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
/**
@ -73,6 +75,8 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
protected boolean isStarted = false;
protected Timer timeoutTimer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -315,6 +319,11 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
setText("START!");
currentScenario.lostFace = false;
// in kioskmode, if no face is found for 60s return to main screen
if(timeoutTimer != null) {
timeoutTimer.cancel();
}
if(isStarted)
currentScenario.start();
}
@ -324,6 +333,19 @@ public class GamingActivity extends AppCompatActivity implements Detector.ImageL
{
currentScenario.pause();
currentScenario.lostFace = true;
// in kioskmode, if no face is found for 60s return to main screen
timeoutTimer = new Timer();
TimerTask timeoutTimerTask = new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(GamingActivity.this, MirrorMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
};
timeoutTimer.schedule(timeoutTimerTask, 60*1000);
}
public void setText(String text)