Android 安卓:通过服务拨打电话

Android 安卓:通过服务拨打电话,android,phone-call,Android,Phone Call,我试着从一家服务公司内部打电话。我使用的代码是: Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + number)); startActivity(intent); 而且它在主要活动中运行良好,但在服务中却不起作用。错误发生在最后一行。无法在服务内拨打电话吗 我如何让这段代码在主要活动中运行?尝试从服务内部拨打电话: Intent intent = new Intent(Inten

我试着从一家服务公司内部打电话。我使用的代码是:

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
而且它在主要活动中运行良好,但在服务中却不起作用。错误发生在最后一行。无法在服务内拨打电话吗


我如何让这段代码在主要活动中运行?

尝试从服务内部拨打电话:

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
startActivity(intent);

如果服务在任何活动之外,请签入清单

这对我不起作用,我会得到错误:android.content.ActivityNotFoundException:
找不到可处理Intent的活动{act=android.Intent.action.CALL flg=0x10000004}