0

I tried to introduce long press. this time using a alertdialog to the 2 options there, play and delete. so I would like to offer longpress for delete and touch for play. How can I do?

code:

    @Override
public void onVideoSelected(final String uri, String mimeType) {



    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setTitle("Select");
    // builder.setMessage("Lorem ipsum dolor ....");
    builder.setItems(new CharSequence[]
                    {getString(R.string.play_video), getString(R.string.remove_video)},
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    switch (which) {
                        case 0:
                            Intent intent = new Intent(Main2Activity.this, MainActivity.class);
                            intent.putExtra("url", uri);
                            startActivity(intent);
                            break;
                        case 1:

                                            File file = new File(uri);
                                            file.delete();

                                            Main2Activity.this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(new File(uri))));

                            break;
                    }
                }
            });
    builder.create().show();

}
Diaconu Liviu
  • 211
  • 4
  • 13

0 Answers0