zmsoft / google-glass-api

Automatically exported from code.google.com/p/google-glass-api
0 stars 0 forks source link

Cannot Update Card Footnote When Using Xamarin.Android and GDK #410

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create a Glass project in Xamarin with the GDK Component.
2.Use a third party Android Library.
3.Create a card with one footnote.
4.Call one of the third-parties's methods that returns data.
5.Change the card's footnote based on that data.

What is the expected output? What do you see instead?
The third-party's method opens up the Speech input intent and then returns back 
to the original card by itself. The card isn't updated in anyway even if I 
hardcode the change to happen before the other method fires. Setting the 
ContentView to a different card right after the method finishes results in a 
black screen.

What version of the product are you using? On what operating system?
Xamarin Studio 4.2.3 Build 54
Google Glasses XE12
Glass Development Kit - Xamarin Component v1.1

Original issue reported on code.google.com by g...@pinskiy.us on 14 Feb 2014 at 6:14

GoogleCodeExporter commented 9 years ago
Hello,

Thanks for the report! However, I have no experience with Xamarin and am not 
sure what is it that you are trying to accomplish here.

Could you share some code snippets so that we can get a better idea of what is 
not working?

Thanks!
Alain

Original comment by ala...@google.com on 18 Feb 2014 at 5:58

GoogleCodeExporter commented 9 years ago
So in Xamarin, all the code is in C# rather than Java. Here is the entire 
activity for the app so far:

using System;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.Glass.App;
using Android.OS;
using Android.Runtime;
using Android.Speech;
using Android.Views;
using Android.Widget;
using Scandit;

namespace GlassDemoApp
{
    [Activity(Label = "Scan Product", MainLauncher = true, Icon = "@drawable/icon")]
    [IntentFilter(new[] { "com.google.android.glass.action.VOICE_TRIGGER" })]
    [MetaData("com.google.android.glass.VoiceTrigger", Resource = "@xml/voicetrigger")]
    public class ScanActivity : Activity, Scandit.Interfaces.IScanditSDKListener
    {
        private ScanditSDKBarcodePicker scanner;
        public static string appKey = "Some App Key";
        public string product = "No Product Found";
        public int image = @Resource.Drawable.icon;
        public string price = "Free";
        public string speechResults = null;
        public string quantity = "Quantity: 5";

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Setup the barcode scanner
            scanner = new ScanditSDKBarcodePicker(this, appKey);
            scanner.OverlayView.AddListener(this);
            // Start scanning
            scanner.StartScanning();
            // Show scan user interface
            SetContentView(scanner);
        }

        public void DidScanBarcode(string barcode, string symbology) {
            //Set results to card
            //string results = String.Format("{0}, '{1}'", symbology, barcode);
            string results = String.Format("{0}", barcode);

            if (results == "072250010788") {
                product = "Mrs. Freshley's Pecan Twirls - Pack of 8";
                image = @Resource.Drawable.pecan;
                price = "$5.99";
            } else if (results == "086719803002") {
                product = "La Primera Tortilla Chips";
                image = @Resource.Drawable.chips;
                price = "$4.99";
            } else if (results == "076296000192") {
                product = "Crescent Creamery 2% Milk - Half Gallon";
                image = @Resource.Drawable.milk;
                price = "$2.99";
            };

            Card card = createCard(price, quantity);
            SetContentView(card.ToView());
        }

        public Card createCard(string price) {
            Card card = new Card(this);
            card.SetText(product);
            card.AddImage(image);
            card.SetFootnote(price);
            return card;
        }

        public Card createCard(string price, string quantity) {
            Card card = new Card(this);
            card.SetText(product);
            card.AddImage(image);
            card.SetFootnote(price + "    " + quantity);
            return card;
        }

        public void DidCancel() {
            var card = new Card(this);
            //Set results to card
            string results = String.Format("Cancel was pressed.");
            card.SetFootnote(results);
            //Show card
            SetContentView(card.ToView());
        }

        public void DidManualSearch(string text) {
            var card = new Card(this);
            //Set results to card
            string results = String.Format("Search was used.");
            card.SetText(results);
            //Show card
            SetContentView(card.ToView());
        }
    }
}

What this does now is scan a barcode and display product information and an 
image. This is a demo, so all the prices and products are hardcoded. What I 
expected to happen was that I create a card with just the price in the 
footnote, call the speech recognizer after a delay, collect the results, and 
then show the same card but with the price AND the quantity in the footnote.

Original comment by g...@pinskiy.us on 18 Feb 2014 at 7:45

GoogleCodeExporter commented 9 years ago
Hello,

I don't think there is any issue with the GDK as `setContentView` should 
properly update the Activity's content view.

Unfortunately, I am not sure who else in this issue tracker would be able to 
help you with any Xamarin specific issues. My suggestion would be to post your 
questions on StackOverflow and use Xamarin related tags.

Best,
Alain

Original comment by ala...@google.com on 18 Feb 2014 at 10:00