nicolas2k / google-glass-api

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

The method execute() is undefined for the type Mirror.Timeline.Insert #359

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create an Android project with the code shown below
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
Google Glass (ICS) + Eclipse 3.7 + OS X

Please provide any additional information below.
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.google.api.client.http.InputStreamContent;
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.NotificationConfig;
import com.google.api.services.mirror.model.TimelineItem;

public class InsertTimelineItem extends Activity
{
// original code:
// https://developers.google.com/glass/v1/reference/timeline/insert 
// error message:
// The method execute() is undefined for the type Mirror.Timeline.Insert 

   @Override
   protected void onCreate(Bundle savedInstanceState)
   {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }

     /**
      * Insert a new timeline item in the user's glass with an optional
      * notification and attachment.
      *
      * @param service Authorized Mirror service.
      * @param text timeline item's text.
      * @param contentType Optional attachment's content type (supported content
      *        types are "image/*", "video/*" and "audio/*").
      * @param attachment Optional attachment stream.
      * @param notificationLevel Optional notification level, supported values are
      *        {@code null} and "AUDIO_ONLY".
      * @return Inserted timeline item on success, {@code null} otherwise.
      */
     public static TimelineItem insertTimelineItem(Mirror service,
                                                   String text,
                                                   String contentType,
                                                   InputStream attachment,
                                                   String notificationLevel)
     {
       TimelineItem timelineItem = new TimelineItem();
       timelineItem.setText(text);

       if (notificationLevel != null && notificationLevel.length() > 0) {
         timelineItem.setNotification(new NotificationConfig().setLevel(notificationLevel));
       }

       try {
         if (contentType != null && contentType.length() > 0 && attachment != null) {
           // Insert both metadata and attachment.
           InputStreamContent mediaContent = new InputStreamContent(contentType, attachment);
           return service.timeline().insert(timelineItem, mediaContent).execute();
         } else {
           // Insert metadata only.
           return service.timeline().insert(timelineItem).execute();
         }
       } catch (IOException e) {
         System.err.println("An error occurred: " + e);
         return null;
       }
    }

   @Override
   public boolean onCreateOptionsMenu(Menu menu)
   {
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
   }
}

Original issue reported on code.google.com by ocampes...@gmail.com on 11 Jan 2014 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by ala...@google.com on 13 Jan 2014 at 6:00