Adding and Editing Items Developed for Android TV
Android TV isn’t really designed for inputting data. There’s no keyboard on most devices, and although there’s a virtual onscreen keyboard, using it with a standard TV remote control can be a real pain.
For that reason, the BrowseFragment doesn’t really have a built-in way for adding items to the database. But without a way to add items to the database, how are you going to test your app?
The trick is to launch the TaskEditActivity on your emulator, directly from Android Studio. Once the TaskEditActivity is running, you can use it to save tasks to the database. Your users can’t launch TaskEditActivity directly from the app, but you can launch it from Android Studio for testing purposes.
Because TVs aren’t a good way to input data, it probably doesn’t make sense to have a permanent Add Item button on the Tasks app for TVs. The technique in this section is a good way to test your app, but most users will expect your TV Tasks app to sync with their apps on their phones. Cloud storage is not covered in this book, but take a look at Google Cloud Save for one potential way to sync your tasks between devices.
To launch TaskEditActivity, open the TaskEditActivity.java file and right-click on TaskEditActivity. Then choose Run ‘TaskEditActivity’.
The TaskEditActivity should run on your emulator, and you should be able to save a new task into your database. If you repeat this a few times, you should see a few items in your app.