1

I am new android devloper

youtube url click crash application I do not know how to fix this error. activitydetails.java works on these. Click notification.java to crash. Below is the image given. image

        adapter.setOnItemClickListener((view, p, position) -> {
            switch (p.content_type) {
                case "youtube": {


                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + post.video_id));

                    // Check if the youtube app exists on the device
                    if (intent.resolveActivity(getPackageManager()) == null) {
                        // If the youtube app doesn't exist, then use the browser
                        intent = new Intent(Intent.ACTION_VIEW,
                                Uri.parse("http://www.youtube.com/watch?v=" + post.video_id));
                    }

                    startActivity(intent);


                }
                case "Url": {
//                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + post.video_id));
//                    intent.putExtra("video_url", post.video_url);
//                    startActivity(intent);
                    break;
                }
                case "Upload": {
//                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + post.video_id));
//                    intent.putExtra("video_url", sharedPref.getApiUrl() + "/upload/video/" + post.video_url);
//                    startActivity(intent);
                    break;
                }
                default: {
                    Intent intent = new Intent(getApplicationContext(), ActivityImageSlider.class);
                    intent.putExtra("position", position);
                    intent.putExtra("recipe_id", post.recipe_id);
                    startActivity(intent);
                    break;
                }
            }
        });
atozcodes
  • 1
  • 2
  • 13

0 Answers0