Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showcase ambient mode / screen timeout handling #356

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.facebook.react.defaults.DefaultReactActivityDelegate;
import com.google.android.gms.cast.framework.CastContext;

import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;

public class MainActivity extends ReactActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
Expand All @@ -19,6 +21,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
} catch (Exception e) {
// cast framework not supported
}

// Prevent going into ambient mode on Android TV devices / screen timeout on mobile devices during playback.
// If your app uses multiple activities make sure to add this flag to the activity that hosts the player.
// Reference: https://developer.android.com/training/scheduling/wakelock#screen
getWindow().addFlags(FLAG_KEEP_SCREEN_ON);
}

/**
Expand Down