2 package jp
.gr
.java_conf
.ofnhwx
.olib
.utils
;
4 import android
.content
.Context
;
5 import android
.content
.Intent
;
6 import android
.content
.pm
.PackageManager
.NameNotFoundException
;
7 import android
.net
.Uri
;
8 import android
.text
.TextUtils
;
11 * 電話関連の処理をまとめたユーティリティクラス.
14 public abstract class OPhone
{
16 private static final String SIP
= "sip";
17 private static final String TEL
= "tel";
20 * 指定された番号に発信(android.permission.CALL_PHONE, android.permission.CALL_PRIVILEGED).
24 public static final void call(Context context
, String number
) {
25 call(context
, TEL
, number
);
34 public static final void call(Context context
, String scheme
, String number
) {
35 if (TextUtils
.isEmpty(number
)) {
38 Uri uri
= Uri
.fromParts(checkScheme(scheme
), number
, null);
39 Intent call
= new Intent(Intent
.ACTION_CALL
, uri
);
40 call
.setFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
);
41 context
.startActivity(call
);
49 public static final boolean checkValidScheme(String scheme
) {
51 checkSchemeWithThrow(scheme
);
53 } catch (NameNotFoundException e
) {
58 private static final String
checkSchemeWithThrow(String scheme
) throws NameNotFoundException
{
59 if (SIP
.equals(scheme
)) {
62 if (TEL
.equals(scheme
)) {
65 throw new NameNotFoundException();
68 private static final String
checkScheme(String scheme
) {
70 return checkSchemeWithThrow(scheme
);
71 } catch (NameNotFoundException e
) {