android - how to catch exception for call? -


on app i'have make call number. code work's fine on mobile phone, on tablet (that can't make call) app crashed. want catch exception.

 try{           string todial = "tel:092168*****";           startactivity(new intent(intent.action_call, uri.parse(todial)));}   catch(exception e){       toast.maketext(getapplicationcontext(), "chiamata non supportata", toast.length_long).show();                       } 

but don't work. idea? sorry bad english

i think should first check whether intent available or not code below

public static boolean isavailable(context ctx, intent intent) {            final packagemanager mgr = ctx.getpackagemanager();            list<resolveinfo> list =               mgr.queryintentactivities(intent,                   packagemanager.match_default_only);            return list.size() > 0;  } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -