簡體   English   中英

Android Wear電話

[英]android wear phone call

我有兩個問題

  1. 我們可以通過Android Wear應用程序以編程方式撥打電話嗎?
  2. 我在Android Wear應用上創建了自定義通知 當用戶點擊自定義通知上的操作時,是否可以打開移動撥號器應用程序?

任何幫助將不勝感激。

謝謝。

是的,我有可能。 嘗試使用:

yes thing it is possible. try to use:

/*start a direct call, make sure you have call permission declared on your manifest
*<uses-permission android:name="android.permission.CALL_PHONE" />
*/
public static void phoneCall(String n, Activity currentActivity) {
    char ench[] = n.toCharArray();
    String tel = "";
    for (int i = 0; i < ench.length; i++) {
        if (ench[i] == '#')
            tel = tel + Uri.encode("#");
        else
            tel = tel + ench[i];
    }
    String toDial = "tel:" + tel;// msgbox(Intent.ACTION_ALL_APPS);
    currentActivity.startActivityForResult(
            new Intent(hasPermission(currentActivity,
                    permission.CALL_PHONE) ? Intent.ACTION_CALL
                    : Intent.ACTION_DIAL, Uri.parse(toDial)), 1024);

}
//open phonne compositor with phone number as n
public static void phoneDial(String n, Activity currentActivity) {
    char ench[] = n.toCharArray();
    String tel = "";
    for (int i = 0; i < ench.length; i++) {
        if (ench[i] == '#')
            tel = tel + Uri.encode("#");
        else
            tel = tel + ench[i];
    }
    String toDial = "tel:" + tel;// msgbox(Intent.ACTION_ALL_APPS);
    Intent intent=new Intent(Intent.ACTION_DIAL,
            Uri.parse(toDial));
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
    currentActivity.startActivityForResult(intent, 1024);

}
//control if your application have some permission
public static boolean hasPermission(Context context, String permission) {
        int res = context.checkCallingOrSelfPermission(permission);
        return (res == PackageManager.PERMISSION_GRANTED);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM