AlexaAndroid
AlexaAndroid copied to clipboard
How to get the response in text format besides Audio response?
hello @willblaschko , @wantitmore ,@prasannakumark
I am trying to display the weather information on device UI. for that when we ask question to Alexa, it supposed to give response of type "Speak " and "RenderTemplate". The RenderTemplate directive will have the weather information in text format.
when i check the AvsResponse i am getting only AvsSpeakItem only .How to get the "Render " object which the actual information about the weather to show it in User interface. any Ideas please?
You must check your alexa products first, when you create a new product. there have a section "capability" need select "Display Cards With Media" then you will get "RenderTemplate" data. https://drive.google.com/file/d/1qJJm_FR5T3qBdSpYk9w-4UJHdKosjG5e/view
@RayHuangDev I've done that. In which class can we then get the RenderTemplate? By the way your link does not work!
@Ehsanta83 you can copy link and paste on browser, it's a pic about alexa product setting page BTW, this sample has no AvsRenderTemplate class, need create by your own
@RayHuangDev Do you have an example of creating it on your own which you can share with us? It would be much appreciated.
@Ehsanta83 here is code below, you can change parameters by your own
public class AvsRenderTemplateItem extends AvsItem { private String mHeaderName; private Payload mPayload;
public AvsRenderTemplateItem(String token, String headerName, Payload payload) {
super(token);
mHeaderName = headerName;
mPayload = payload;
}
public String getmHeaderName() {
return mHeaderName;
}
public Payload getPayload() {
return mPayload;
}
}
@RayHuangDev Thank you for sharing the code. How do you use it? I mean in this project.
add this class in "interfaces" folder such as link below: https://github.com/willblaschko/AlexaAndroid/tree/master/libs/AlexaAndroid/src/main/java/com/willblaschko/android/alexa/interfaces
you can use in BaseActivity->checkQueue()-> else if (current instanceof AvsRenderTemplateItem ){ ... }
https://github.com/willblaschko/AlexaAndroid/blob/master/app/src/main/java/com/willblaschko/android/alexavoicelibrary/BaseActivity.java