Search code examples
tizen-wearable-sdk

tizen:app-control in Gear S


The rich Notification documentation tell us we can do something like this:

SrnImageAsset checkInIcon = new SrnImageAsset(context, "checkin_icon", checkInIconBitmap); myAction.setIcon(checkInIcon); myAction.setPackage("com.mypackage.myapp"); myAction.setData(Uri.parse("checkin://venue_id=12345"));

It means we can open a custom app with a custom app-control.

But i don't know how to make it work. I don't even know which package I have to set. "com.mypackage.myapp" seems to be the android package because the tizen one has a different format.


What I do:

Config.xml:

    <tizen:app-control>
        <tizen:operation name="http://tizen.org/appcontrol/operation/view"/>
        <tizen:src name="index.html"/>
        <tizen:uri name="myapp"/>
    </tizen:app-control>

</widget>

Java:

myAction.setPackage("L1NG56dhCi");
myAction.setData(Uri.parse("myapp://newsId=1"));

When I click on the action icon in the notification of the Gear, I see in the log (without more interesting info): [app_control_send_launch_request]LAUNCH_REJECTED(0xc0000000)


Solution

  • Ok found it! The secret is to never call setPackage(), only this:

    SrnRemoteLaunchAction myAction = new SrnRemoteLaunchAction("Open the news");
    Bitmap checkInIconBitmap = BitmapFactory.decodeResource(context.getResources(),  R.drawable.ic_notif);
    myAction.setIcon( new SrnImageAsset(context, "checkin_icon", checkInIconBitmap));
    
    myAction.setData(Uri.parse("myapp://test"));
    myAction.setOperation("http://tizen.org/appcontrol/operation/view");
    myRichNotification.addAction(myAction);