In this video it shows the steps to access the HDMI Passthrough input in your Android TV App. It shows the inputs whatever is passed through the HDMI cable in the TvView widget of your TV App.
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details:
package com.programmerworld.hdmiinputintvapp;
import androidx.appcompat.app.AppCompatActivity;
import android.media.tv.TvContract;
import android.media.tv.TvView;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView textView;
private TvView tvView;
private String stringInputID = "com.droidlogic.tvinput/.services.Hdmi1InputService/HW5";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
tvView = findViewById(R.id.tvView);
}
public void buttonShowHDMI(View view){
Uri uri = TvContract.buildChannelUriForPassthroughInput(stringInputID);
tvView.tune(stringInputID, uri);
textView.setText("SUCCESS");
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.436"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.097" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="77dp"
android:layout_marginTop="34dp"
android:onClick="buttonShowHDMI"
android:text="Show HDMI"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.media.tv.TvView
android:id="@+id/tvView"
android:layout_width="861dp"
android:layout_height="378dp"
android:layout_marginStart="50dp"
android:layout_marginTop="29dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button" />
</androidx.constraintlayout.widget.ConstraintLayout>
Screenshots:
Excerpt:
The given content pertains to a tutorial video demonstrating how to access the HDMI Passthrough input on an Android TV app. It guides users on how to display inputs passed through the HDMI cable in the TvView widget. The video provides practical assistance with the associated source code being shared. Regular updates, further clarifications or to submit feedback, the author invites viewers to make use of the provided contact information. Relevant XML layouts are illustrated and the guide provides suggestions for standard debugging practices, like displaying “SUCCESS” when the HDMI is successfully shown.