Extract all tv channel in tv using tvinputmanager in android

Home Activity.java Plese helped me explain how it gets the list of all channels

public class MainActivity extends Activity {
    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final Button button = (Button)findViewById(R.id.ping_button);
         Button access = (Button)findViewById(R.id.btnaccess);
         Button justtest=(Button)findViewById(R.id.btntest);
         button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {

              System.out.print("Listing TvInputManager TvInputInfo list:\n");
        TvInputManager tvInputManager=(TvInputManager)getApplicationContext().getSystemService(TV_INPUT_SERVICE);
        List<TvInputInfo> tvInputList=tvInputManager.getTvInputList();
        Log.i("TV", "Got "+tvInputList.size()+ " TvInputsInfos.");
        for (int i=0; i<tvInputList.size(); i++) {
            Log.i("TV", tvInputList.get(i).getId());
        }

             }
         });

        Intent intent = new Intent();
        intent.setAction("com.futarque.StartTvService");
        sendBroadcast(intent);


        justtest.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                System.out.print("Listing TvInputManager TvInputInfo list:\n");
                TvInputManager tvInputManager=(TvInputManager)getApplicationContext().getSystemService(TV_INPUT_SERVICE);
                List<TvInputInfo> tvInputList=tvInputManager.getTvInputList();
                Log.i("TV", "Got "+tvInputList.size()+ " TvInputsInfos.");
                for (int i=0; i<tvInputList.size(); i++) {
                    Log.i("TV", tvInputList.get(i).getId());
                }

            }
        });
        Intent intent = new Intent();
        intent.setAction("com.futarque.StartTvService");
        sendBroadcast(intent);

      

+3


source to share





All Articles