1
votes

I have 2 questions

  1. Can we make phone calls programatically from Android wear app?
  2. I have created a custom notifcation on Android wear app. Is it possible to open the mobile dialer app, when user tap on the action on custom notification?

Any help woud be appreciated.

Thanks.

1
I'm also interested in this. Did you figure out if this is possible?Jani

1 Answers

0
votes

yes i thing it is possible. try to use:

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