Youtube player crashes with giving java.lang.IllegalStateException: android.os.DeadObjectException in Android

爱⌒轻易说出口 提交于 2019-12-06 06:17:26
Pravinsingh Waghela

Well above code work fine now, All what was creating that exception was that, some of the VideoId were null and some were "" hence the VideoId whose value was "" was creating an the exception to me as I was only checking for null values and not for "" value of VideoId. Now the issue is resolved.

If any one need to use Youtube Android API code can simply use the above code. It works fine even in Sherlock Activity.

Thanks for the feedsbacks of those who tried and supported me.

Try catching all exceptions instead of only catching

IllegalStateException

replace your code like this

if(sVideoId!=null){
            try{
             YPlayer.loadVideo(sVideoId);
            }
            catch(Exception e){
                e.printStackTrace();
            }
        }

handle all exceptions. Do something when you get

android.os.DeadObjectException

Kindly Update your app to the latest version of Youtube and it starts working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!