2015-04-23 51 views
1

我有2个问题的Android Wear电话

  1. 我们能不能打电话从编程的Android Wear应用?
  2. 我在Android Wear应用上创建了一个custom notifcation。当用户点击自定义通知上的操作时,是否可以打开移动拨号程序?

任何帮助将不胜感激。

谢谢。

+0

我也对此感兴趣。你有没有想过这是否可能? – Jani

回答

0

是的,我的事情是可能的。尝试使用:

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); 
}