我有 2 个问题
- 我们可以通过 Android Wear 应用程序以编程方式拨打电话吗?
- 我在 Android Wear 应用上创建了一个自定义通知。当用户点击自定义通知上的操作时,是否可以打开移动拨号器应用程序?
任何帮助将不胜感激。
谢谢。
我有 2 个问题
任何帮助将不胜感激。
谢谢。
是的,我认为这是可能的。尝试使用:
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);
}