1

I have problem integrating GDK Glassware and Mirror API Glassware as described here. I need to open GDK glassware application using Mirroe api Glassware app MenuItem. Can I send data bundle with intent. Does anybody have an idea about that.

Thank you.

Sanath
  • 493
  • 7
  • 22
  • possible duplicate of [How can I start an intent from a card in Google Glass](http://stackoverflow.com/questions/18790374/how-can-i-start-an-intent-from-a-card-in-google-glass) – mimming Jan 07 '14 at 06:42
  • Can I send data using this method?. This is not answering to my problem. But thank you very much. – Sanath Jan 07 '14 at 08:07
  • 1
    Nice question, is it possible to pass data from timeline card to native app, like we do in normal android using bundle? – Amalan Dhananjayan Jan 07 '14 at 09:06

2 Answers2

5

I have finally figured out a way to do that

  1. First add your custom scheme to android activity tag in AndroidManifest.xml

     
      <activity
            android:name="com.sanath.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
              <data android:scheme="com.sanath.scheme" />
              <action android:name="android.intent.action.VIEW" />
              <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/vision_voice_trigger" />
        </activity>
  2. Then in Glassware timeline MenuItem add like following

    
    new MenuItem(){
    Action = "OPEN_URI",
    Payload = "com.sanath.scheme://open/Welcome/2014",
    Values = new MenuValue[]
            {
             new MenuValue()
             {
                DisplayName  = "Open",
                State = "DEFAULT"
             },
             new MenuValue()
             {
                DisplayName  = "Launching",
                State = "PENDING"
             },
             new MenuValue()
             {
                 DisplayName  = "Launched",
                 State = "CONFIRMED"
             },
             },
            },
        }
    
  3. Then inside your Activity OnCreate method you can get data as following

    
       Uri data = getIntent().getData();
            List params = data.getPathSegments();
            String param0 = params.get(0); // "welcome"
            String param1 = params.get(1); //"2014"
    
        String welcomeMsg = param0+" to "+param1;
    
        /*show time line card
         * */
        Card welcomeCard =new Card(this);
        welcomeCard.setText(welcomeMsg);
        welcomeCard.setFootnote(param1);
        View view =welcomeCard.toView();
    
        setContentView(view);
    

Hope this will help others

StanleyZheng
  • 4,008
  • 3
  • 21
  • 24
Sanath
  • 493
  • 7
  • 22
3

It is not possible to provide data through bundle, but you can use query parameters or hash fragment in your URI to provide the necessary data.

Example:

myscheme://<SOME_PATH>?param1=value1&param2&value2

Then, in your GDK Glassware, simply parse the query parameters and process their values.

Alain
  • 6,044
  • 21
  • 27