Monday 2 November 2020

Drop event not detected between activities API 22+

I want to give the user the ability to drag from one activity to another, within my app, but the drop event not detected

Starting Drag operation in the First activity:

public boolean onItemLongClick(AdapterView<?> aParent, View aView, int aPos, long aID) {

    View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(aView);

    Intent intent = new Intent();
    intent.putExtra("Phase", "Phase");    

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        aView.startDragAndDrop(ClipData.newIntent(DRAG_N_DROP_DESCRIPTION, intent), shadowBuilder, null, 0);
    } else {
        aView.startDrag(ClipData.newIntent(DRAG_N_DROP_DESCRIPTION, intent), shadowBuilder, null, 0);
    }


    startSecondActivity();

    finish();

    return true;
}

Receiving Drop Operation in the Second activity

public boolean onDrag(View aView, DragEvent aEvent) {

    switch (aEvent.getAction()) {
          case DragEvent.ACTION_DRAG_STARTED:
                 This is not called on Android 22+
                 break;

          case DragEvent.ACTION_DROP:
          This is not called on Android 22+
                 break;
    }

    return true;
}

There will be 50 points reward for the solution.



from Drop event not detected between activities API 22+

No comments:

Post a Comment