[브라우저를 못찾는 케이스 ActivityNotFoundException]No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://ddolcatmaster.tistory.com/
특정 폰에서 크롬과 같은 브라우저를 못찾는 케이스가 있는 것 같다.
Fatal Exception: android.content.ActivityNotFoundException: No Activity found to handle Intent
{ act=android.intent.action.VIEW dat=https://ddolcatmaster.tistory.com/ }
at android.app.Instrumentation.checkStartActivityResult + 1781(Instrumentation.java:1781)
at android.app.Instrumentation.execStartActivity + 1501(Instrumentation.java:1501)
at android.app.Activity.startActivityForResult + 3760(Activity.java:3760)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java)
at android.app.Activity.startActivityForResult + 3721(Activity.java:3721)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java)
at android.app.Activity.startActivity + 4033(Activity.java:4033)
at android.app.Activity.startActivity + 3999(Activity.java:3999)
at ddolcatmaster.mypowermanagement.MainActivity$14.onClick(MainActivity.java)
at android.view.View.performClick + 4788(View.java:4788)
at android.view.View$PerformClick.run + 19881(View.java:19881)
at android.os.Handler.handleCallback + 739(Handler.java:739)
at android.os.Handler.dispatchMessage + 95(Handler.java:95)
at android.os.Looper.loop + 135(Looper.java:135)
at android.app.ActivityThread.main + 5345(ActivityThread.java:5345)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke + 372(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 947(ZygoteInit.java:947)
at com.android.internal.os.ZygoteInit.main + 742(ZygoteInit.java:742)
기존로직에 try~catch문에 ActivityNotFoundException 를 걸어 웹뷰를 호출하였다.
[해결책]
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {//api 26
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://ddolcatmaster.tistory.com/")));
}catch (ActivityNotFoundException e){
startActivity(new Intent(MainActivity.this, WebviewActivity.class)); //오류발생시 웹뷰로 처리
}
}else {
startActivity(new Intent(MainActivity.this, WebviewActivity.class));
}
오류를 해결 후 Close할때마다 찍히는 빨간색 Closed 도장 찍는 맛이 일품이였다.
이제 이 기능도 조만간 종료되는구나…..