NotificationExtension中的控件事件

时间:2013-10-30 08:39:24

标签: android android-notifications sony sony-smartwatch

有人知道我是否可以在SmartWatch的NotificationExtension中输入控制事件?

例如:如果出现通知,我可以将其向下滑动以将其删除。

我尝试添加onSwipe:

public void onSwipe(int direction) {
             switch (direction) {
        case Control.Intents.SWIPE_DIRECTION_UP:
            break;
        case Control.Intents.SWIPE_DIRECTION_LEFT:
            break;
        case Control.Intents.SWIPE_DIRECTION_DOWN:
            //something todo, forexample:
            Toast.makeText(this, "Action 1", Toast.LENGTH_LONG).show();
            break;
        case Control.Intents.SWIPE_DIRECTION_RIGHT:
            break;
        default:
            break;
    }
} 

在该示例代码中,我没有收到吐司。我不知道在哪里可以实现通知的控件,所以我想onSwipe我可以处理NotificationExtension中的控件。有谁知道正确的解决方案?谢谢

1 个答案:

答案 0 :(得分:2)

NotificationExtension中无法实现这一点。如果您希望能够处理滑动事件,则需要使用ControlExtension。

如果您想在您的应用中使用Control和Notification扩展功能,我们在索尼开发者世界的博客中发布了一个教程:

http://developer.sonymobile.com/2013/12/26/using-both-the-control-notification-apis-for-customised-uis-in-your-smartwatch-2-extension-code/