0

Starting to develop an app these days, i'm stuck trying to open a "window" when the screen is touched in the widget.

In Code Examples (sdk), we can see this in the Event Widget, when you click in the screen, a "window" is opened, and you can see the events there.

I follow the code to see how can i do this:

in NotificationWidgetExtension : SmartExtensionUtils : onTouch event

Intent intent = new Intent(Widget.Intents.WIDGET_ENTER_NEXT_LEVEL_INTENT);
sendToHostApp(intent);

In WidgetExtension

protected void sendToHostApp(final Intent intent) {
    intent.putExtra(Widget.Intents.EXTRA_AEA_PACKAGE_NAME, mContext.getPackageName());
    intent.setPackage(mHostAppPackageName);
    mContext.sendBroadcast(intent, Registration.HOSTAPP_PERMISSION);
}

Trying to replicate but i'm not being successful. Is there any place i can read about it, or someone can help me on this?

Otuyh
  • 2,384
  • 5
  • 22
  • 40
  • Are you running in emulation, or on the device? Can you confirm your code compiled correctly? Can you make _anything_ run? – Floris Aug 06 '13 at 18:10
  • I'm using a watch. It's all runing, the thing is, i want to know more about this window that is opened. Can i open any layout with this? – Otuyh Aug 06 '13 at 18:15
  • Oh, i see now that the window that is opened is really the extension layout.. – Otuyh Aug 06 '13 at 18:26

1 Answers1

2

I think you are looking at three different APIs - the Widget API, the Notification API and the Control API.

The onTouch code that you reference is a part of the utility classes of the SDK, and is there to help you if you have made an extension that have both implemented the Notification API and the Widget API. When in the Widget view on the watch, and you have overridden the NotificationWidgetExtension class, the onTouch event will be delivered to the mentioned method. It will basically show the first available (and not read) notification.

You mention "window" etc, and I am guessing that you want to create an application on the SmartWatch. This is done through the Control API. Take a look at the SampleControlExtension contained in the SDK. Check this answer, to get information on how to start a Control extension from your own extension. E.g. if you create a Widget+Control extension, you could start the Control extension in the onTouch method of your Widget.

Community
  • 1
  • 1
Jerker
  • 805
  • 4
  • 9
  • Hey Jerker, thanks for the answer, but i still have one question. I'm using this in onTouch of widget: Intent intent = new Intent(Control.Intents.CONTROL_START_REQUEST_INTENT); sendToHostApp(intent); Ok, i'm starting the control. How can i know that i'm coming from widget, and not clicking in the extension icon? – Otuyh Aug 09 '13 at 12:46
  • Hi Hor, there is currently no way to really distinguish between a widget-started extension, and a user-started extension. I would suggest using e.g. your app preferences to set a flag in the Widget onTouch method. And when the Control extension has been started, check the flag to distinguish between the two situations. Not perfect, but doable. – Jerker Aug 12 '13 at 12:48