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
Post a Comment