samedi 9 mai 2015

Check SMS and DIal support before Intent

well i have this code to send sms via intent , and to call a number :

 public void Call(String s) {//Appeler
    String url = "tel:" + s;
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
    startActivity(intent);
}
public void Sms(String s){
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", s, null)));
}

it looks fine in my phone , no crash , but in my tablet which doesn't support sms and call (doesn't have sim card and sms and dial app) the app crashes when callin these methods , so how to handle that exception ?

Aucun commentaire:

Enregistrer un commentaire