How to handle the ActivityNotFoundException?

后端 未结 4 1660
别跟我提以往
别跟我提以往 2021-01-18 07:31

In my app , I need to use startActivity to see the content of the file , or use the default application to open the certain file , but sometimes the android system may not i

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 08:09

    You can use resolveActivity method

        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }else {
            Toast.makeText(this,"No suitable app found!",Toast.LENGTH_SHORT).show();
        }
    

提交回复
热议问题