【问题标题】:Can you detect a swipe up on android heads up notification你能检测到安卓抬头通知上的滑动吗
【发布时间】:2018-12-27 04:07:43
【问题描述】:

当用户在提示通知上左右滑动时,我知道您可以通过setDeleteIntent 捕获此手势并编写要触发的自定义意图。

但是,当用户打盹通知时,是否可以检测到用户何时向上滑动提醒通知,因为此时他们没有将其关闭,因此删除 Intent 永远不会被触发?

我想知道用户是向上还是向左或向右滑动通知。

【问题讨论】:

    标签: java android notifications swipe gesture


    【解决方案1】:

    如果你开始检测common gestures,它对你有用吗?我相信通知也可以遵循同样的方法。

    public class MainActivity extends Activity {
    @Override
    public boolean onTouchEvent(MotionEvent event){
    
    int action = MotionEventCompat.getActionMasked(event);
    
    switch(action) {
        case (MotionEvent.ACTION_DOWN) :
            Log.d(DEBUG_TAG,"Action was DOWN");
            return true;
        case (MotionEvent.ACTION_MOVE) :
            Log.d(DEBUG_TAG,"Action was MOVE");
            return true;
        case (MotionEvent.ACTION_UP) :
            Log.d(DEBUG_TAG,"Action was UP");
            return true;
        case (MotionEvent.ACTION_CANCEL) :
            Log.d(DEBUG_TAG,"Action was CANCEL");
            return true;
        case (MotionEvent.ACTION_OUTSIDE) :
            Log.d(DEBUG_TAG,"Movement occurred outside bounds " +
                    "of current screen element");
            return true;
        default :
            return super.onTouchEvent(event);
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-07
      • 1970-01-01
      • 2011-05-06
      • 2016-02-04
      • 2018-08-12
      • 1970-01-01
      相关资源
      最近更新 更多