Android MediaPlayer.Create() returns null

前端 未结 3 1011
青春惊慌失措
青春惊慌失措 2020-12-07 02:28

I am developing an Android App that plays some sounds. For that I am creating an object of MediaPlayer. Below is the code:

mp = MediaPlayer.create(this, R.ra         


        
3条回答
  •  旧巷少年郎
    2020-12-07 03:17

    It can happen that it returns null because the device doesn't support playing audio i.e watch.

    To check if device supports MediaPlayer you can do a null check on MediaPlayer.create()

    I found it on google santa-tracker app

提交回复
热议问题