Determining if an Activity exists on the current device?

前端 未结 5 1740
攒了一身酷
攒了一身酷 2020-11-29 06:28

Is there a way to check and see if an Activity exists on your device? If I have a youtube video link I want to specify it open in the YouTube PlayerActivity. However, I don\

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 07:00

    I don't think I can catch the runtime exception

    Actually, this works:

    try {
        startActivity(new Intent(..));
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, "Not installed.", LENGTH_SHORT).show();
    }
    

提交回复
热议问题