Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
try {
final Socket socket = serverSocket.accept();
final boolean[] accept = { false };
new Handler(Looper.getMainLooper()).post(() -> {
new AlertDialog.Builder(lobbyActivity)
.setTitle("Incoming Request")
.setMessage("Incoming Game Request")
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
accept[0] = true;
try {
socket.getOutputStream().write( 1);
} catch (IOException e) {
e.printStackTrace();
}
new Handler(Looper.getMainLooper()).post(() -> {
Log.d("GAME", "Starting game from connection.");
AndroidLauncher.network = new NetworkHandler(socket);
Intent intent = new Intent(lobbyActivity, AndroidLauncher.class);
lobbyActivity.startActivity(intent);
});
})
.setNegativeButton(android.R.string.no, (dialog, which) -> {
accept[0] = false;
try {
socket.getOutputStream().write(0);
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
});
} catch (IOException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.