This repository has been archived by the owner on May 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
2,540 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
.idea/caches | ||
.idea/modules.xml | ||
.idea/navEditor.xml | ||
local.properties | ||
.DS_Store | ||
build | ||
.gradle/ | ||
captures | ||
.externalNativeBuild | ||
.cxx | ||
*.apk | ||
*.ap_ | ||
*.aab | ||
*.dex | ||
*.class | ||
bin/ | ||
gen/ | ||
out/ | ||
*.log | ||
.navigation/ | ||
captures/ | ||
|
||
.externalNativeBuild | ||
.cxx/ | ||
vcs.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Notice | ||
|
||
Alexa Video Sample FireTv App Only Integration | ||
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
||
****************************** | ||
THIRD PARTY COMPONENTS | ||
****************************** | ||
|
||
This software includes third party software subject to the following copyrights: | ||
|
||
* Android TV starter code - Copyright (C) 2014 The Android Open Source Project | ||
|
||
* AndroidX Leanback 1.0.0 for building Android Tv apps - Copyright (C) 2015 The Android Open Source Project | ||
|
||
* AndroidX ConstraintLayout 1.1.3 for positioning and sizing UI widgets - Copyright © 2008 Google Inc. All Rights Reserved. | ||
|
||
* AndroidX NavigationFragment 2.3.0 for navigating between android components - Copyright 2019 The Android Open Source Project | ||
|
||
* AndroidX NavigationUI 2.3.0 for navigating between android components - Copyright 2018 The Android Open Source Project | ||
|
||
* AndroidX AppCompat 1.1.0 - Copyright © 2008 Google Inc. All Rights Reserved. | ||
|
||
* Gson 2.8.2 for JSON parsing - Copyright 2008 Google Inc. | ||
|
||
* Bumptech Glide Compiler 3.8.0 for Image/Video loading - Copyright 2014 Google, Inc. All rights reserved. | ||
|
||
* Android Material 1.1.0 for UI Material Design - Copyright (C) 2015 The Android Open Source Project | ||
|
||
NOTE: Other license terms may apply to certain, identified software files contained within or distributed with the accompanying software if such terms are included in the directory containing the accompanying software. Such other license terms will then apply in lieu of the terms of the software license above. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
## My Project | ||
# Readme | ||
|
||
TODO: Fill this README out! | ||
This sample-fire-tv-app-only-integration project contains a basic Android TV app that responds to voice requests from users to find and play content. Users can say "Watch [movie title]" or "Find [TV show]" and the app will respond appropriately, without the need to use a remote control. | ||
|
||
Be sure to: | ||
To accomplish this, the app incorporates the VSK Agent Client Library to connect to the on-device VSK Agent, which reports your app’s capabilities to Alexa and routes directives from Alexa to your app. The app follows the "App-only integration" method described in the Amazon developer documentation here: [App-only Integration Overview](https://developer.amazon.com/docs/video-skills-fire-tv-apps/integration-overview-app-only.html). | ||
|
||
* Change the title in this README | ||
* Edit your repository description on GitHub | ||
The app requires some setup and configuration. For example, you need to configure the sample app with your own package name, as well as perform other steps to configure a security profile for the app. Once configured, the app plays up a sample video when you ask Alexa for the video by title. (Note that the code doesn't play the actual content asked for, just some test videos.) | ||
|
||
## Security | ||
The sample app will allow you to see a directive pushed to the app. This preview can give you more of a sense of how Alexa interacts with your app without actually going through the entire implementation with your own app. The sample app does not provide complex logic about how to handle the directives to perform specific actions in the app -- you'll need to work out much of the logic on your own based on your own unique code. | ||
|
||
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. | ||
Additionally, this sample app is meant as a companion to the documentation, not as a starting point or template for your own app (though it could be used as the basis for your app if desired). Almost every video partner that integrates the VSK already has a custom-developed app. The sample app simply provides some context for some of the integration instructions. | ||
|
||
## License | ||
For detailed instructions on setting up the sample app, see the [Step 3: Set Up the Sample App](https://developer.amazon.com/docs/video-skills-fire-tv-apps/set-up-sample-app-app-only.html), [Step 9: Sign Your App and Configure a Security Profile](https://developer.amazon.com/docs/video-skills-fire-tv-apps/sign-your-app-and-configure-security-profile-app-only.html), and [Step 10: Test Utterances and Observe Logs](https://developer.amazon.com/docs/video-skills-fire-tv-apps/test-utterances-and-observe-logs-app-only.html) in the app-only implementation documentation. (Other steps are not necessary if you just want to get the sample app set up and configured.) | ||
|
||
This library is licensed under the Amazon Software License. | ||
An abbreviated version of the instructions are as follows: | ||
|
||
1. Clone this app to your local workspace using `git clone https://github.com/alexa/alexa-sample-fire-tv-app-only-integration.git`. | ||
2. Open the project code in Android Studio and replace the default package name `com.example.vskfiretv.company` in such a way that it is unique. Retain the prefix `com.example.vskfiretv` and replace only the last level `company` with your own unique name. The prefix `com.example.vskfiretv` is mandatory so that we can associate a default catalog for your sample app in the backend. | ||
3. Rebuild the project and make sure the build is fine. | ||
4. Sign your app with your custom key in Android Studio. | ||
5. Get the MD5 and SHA-256 values from your custom key by running "signingReport" in Android Studio. | ||
6. Create a security profile in the Amazon developer console (Settings > Security Profiles) and enter the MD5 and SHA-256 values of your customer key in "Android/Kindle Settings." Then generate a new API key. | ||
7. Enter the API key in your sample app by going to `api_key.txt` file in the asset folder and inserting your API key. This will allow your app to be successfully authenticated by the VSK Agent. | ||
8. Rebuild the project and make sure the build is fine. | ||
9. In the developer console, create a new app and complete all the submission tabs (but don't submit the app). | ||
10. Generate a release APK file (signed with your custom key) and upload it into the Amazon developer console. | ||
11. Attach the security profile to your app so that your app is authorized on the Fire TV. | ||
12. In the developer console, submit your app into Live App Testing (LAT) to allow for backend mapping of your app's ASIN and title to the catalog. | ||
13. Get a Fire TV device and connect your computer to it through adb. (See [Connect to Fire TV through adb](https://developer.amazon.com/docs/fire-tv/connecting-adb-to-device.html).) | ||
14. Inside Android Studio, run the app on your connected Fire TV device. You can monitor adb logs using the following commands when running the app. You will see that the sample app's capabilities are successfully reported in the adb logs. | ||
* `adb logcat | grep "AppAgent" -i` | ||
* `adb logcat | grep "DynamicCapabilityReporter" -i` | ||
15. Open a terminal and run `adb logcat | grep "AlexaDirectiveReceiver" -i`. Then say the test utterance "Alexa, watch Superman" and look for a `SearchAndPlay` directive to get pushed to your app. You will see a random video being played in the sample app, and you can look at the directive payload using adb logs. | ||
16. You can test other utterances such as "Alexa, search for comedies," "Alexa, pause" (while the video is playing), "Alexa, rewind," "Alexa fast forward by 25 seconds," and so on. |
Binary file added
BIN
+27.5 KB
VSKApplicationAgentClientLibrary/VSKApplicationAgentClientLibrary.aar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
configurations.maybeCreate("default") | ||
artifacts.add("default", file('VSKApplicationAgentClientLibrary.aar')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build | ||
/release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
|
||
// signingConfigs { | ||
// firetv { | ||
// storeFile file('/Users/yourname/path/to/androidkeys.jks') | ||
// storePassword var | ||
// keyPassword var | ||
// keyAlias = 'yourandroidkeyalias' | ||
// } | ||
// } | ||
|
||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.2" | ||
defaultConfig { | ||
applicationId "com.example.vskfiretv.company" | ||
minSdkVersion 21 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
// signingConfig signingConfigs.firetv | ||
} | ||
debug { | ||
// signingConfig signingConfigs.firetv | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
implementation 'androidx.leanback:leanback:1.0.0' | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'com.github.bumptech.glide:glide:3.8.0' | ||
implementation 'com.google.code.gson:gson:2.8.2' | ||
implementation 'com.google.android.material:material:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'androidx.navigation:navigation-fragment:2.3.0' | ||
implementation 'androidx.navigation:navigation-ui:2.3.0' | ||
implementation project(path: ':VSKApplicationAgentClientLibrary') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.vskfiretv.company"> | ||
|
||
<uses-feature | ||
android:name="android.hardware.touchscreen" | ||
android:required="false" /> | ||
<uses-feature | ||
android:name="android.software.leanback" | ||
android:required="true" /> | ||
|
||
<!-- This permission allows your app to integrate with VSK Agent --> | ||
<uses-permission android:name="com.amazon.alexa.vsk_app_agent_api.permission.BIND_SERVICE_PERMISSION" /> | ||
|
||
<!-- This permission allows your app to access video content from the internet--> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".VSKReferenceApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<!-- You can declare the app's static capabilities in this way--> | ||
<meta-data android:name="com.amazon.alexa.vsk_app_agent_api.capabilities" android:resource="@raw/static_capabilities" /> | ||
|
||
<activity | ||
android:name=".MainActivity" | ||
android:launchMode="singleTop" | ||
android:banner="@drawable/app_icon_your_company" | ||
android:icon="@drawable/app_icon_your_company" | ||
android:label="@string/app_name" | ||
android:logo="@drawable/app_icon_your_company" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" | ||
android:screenOrientation="landscape"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name=".DetailsActivity" /> | ||
<activity android:name=".PlaybackActivity" /> | ||
<activity android:name=".BrowseErrorActivity" /> | ||
|
||
<!-- You must declare a broadcast receiver which can handle Alexa directives and other Intent messages from the VSK Agent --> | ||
<receiver | ||
android:name=".receiver.AlexaDirectiveReceiver" | ||
android:enabled="true" | ||
android:exported="true" | ||
android:permission="com.amazon.alexa.androidapplicationagent.permission.SEND_DATA"> | ||
<!-- Intent action for receiving an Alexa directive--> | ||
<intent-filter> | ||
<action android:name="com.amazon.alexa.vsk_app_agent_api.ACTION_ALEXA_DIRECTIVE" /> | ||
</intent-filter> | ||
<!-- Intent action requested by VSK agent to an app to report its dynamic capabilities--> | ||
<intent-filter> | ||
<action android:name="com.amazon.alexa.vsk_app_agent_api.ACTION_REPORT_CAPABILITIES" /> | ||
</intent-filter> | ||
</receiver> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<INSERT YOUR API KEY HERE> |
85 changes: 85 additions & 0 deletions
85
app/src/main/java/com/example/vskfiretv/company/BrowseErrorActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2014 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.example.vskfiretv.company; | ||
|
||
import android.app.Activity; | ||
import android.app.Fragment; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.view.Gravity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.ProgressBar; | ||
|
||
/* | ||
* BrowseErrorActivity shows how to use ErrorFragment | ||
*/ | ||
public class BrowseErrorActivity extends Activity { | ||
private static final int TIMER_DELAY = 3000; | ||
private static final int SPINNER_WIDTH = 100; | ||
private static final int SPINNER_HEIGHT = 100; | ||
|
||
private ErrorFragment mErrorFragment; | ||
private SpinnerFragment mSpinnerFragment; | ||
|
||
/** | ||
* Called when the activity is first created. | ||
*/ | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
testError(); | ||
} | ||
|
||
private void testError() { | ||
mErrorFragment = new ErrorFragment(); | ||
getFragmentManager() | ||
.beginTransaction() | ||
.add(R.id.main_browse_fragment, mErrorFragment) | ||
.commit(); | ||
|
||
mSpinnerFragment = new SpinnerFragment(); | ||
getFragmentManager() | ||
.beginTransaction() | ||
.add(R.id.main_browse_fragment, mSpinnerFragment) | ||
.commit(); | ||
|
||
final Handler handler = new Handler(); | ||
handler.postDelayed(() -> { | ||
getFragmentManager() | ||
.beginTransaction() | ||
.remove(mSpinnerFragment) | ||
.commit(); | ||
mErrorFragment.setErrorContent(); | ||
}, TIMER_DELAY); | ||
} | ||
|
||
public static class SpinnerFragment extends Fragment { | ||
@Override | ||
public View onCreateView( | ||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
ProgressBar progressBar = new ProgressBar(container.getContext()); | ||
if (container instanceof FrameLayout) { | ||
FrameLayout.LayoutParams layoutParams = | ||
new FrameLayout.LayoutParams(SPINNER_WIDTH, SPINNER_HEIGHT, Gravity.CENTER); | ||
progressBar.setLayoutParams(layoutParams); | ||
} | ||
return progressBar; | ||
} | ||
} | ||
} |
Oops, something went wrong.