标签: android-phone-call

检测用户是否以编程方式实际拨打了号码

在一个应用程序中,我在 textview 中显示了一些电话号码,用户可以点击它们来拨打它们(在 textview 上autoLink设置为phone)。
当我点击数字时,会显示拨打该号码的选项。
我的问题是:有没有办法确定用户是否实际按下了拨号盘中的拨号按钮来实际拨打电话?

android android-intent android-phone-call

5
推荐指数
1
解决办法
367
查看次数

如何使电话号码在 Android 的文本视图中可点击

我有一个包含电子邮件和电话号码的文本视图。我想要的效果是,当用户点击电子邮件时,它会打开默认的电子邮件应用程序,当用户点击电话号码时,应用程序会将其拉到拨号器中。使用以下代码:

XML:

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/careers_guidance"
            android:id="@+id/careers_guidance_text"
            android:layout_marginStart="20dp"
            android:layout_marginEnd="20dp"
            android:layout_marginTop="5dp"
            android:linksClickable="true"
            android:textColorLink="#0000EE"
            android:autoLink="all"/>
Run Code Online (Sandbox Code Playgroud)

爪哇:

careersGuidance = view.findViewById(R.id.careers_guidance_text);
    careersGuidance.setText(Html.fromHtml("<p>Help with choosing the right course and with thinking about where this might take you in the future.</p>" +
            "<p>Tel: <a href=\"tel:01274433043\">01274 433043</a></p>Email: <a href=\"mailto:careers@bradfordcollege.ac.uk\">careers@bradfordcollege.ac.uk</a>"));
Run Code Online (Sandbox Code Playgroud)

当我运行我的应用程序时,只有电子邮件可点击并按我希望的方式工作,电话号码不可点击或突出显示。

在此处输入图片说明

但是,我注意到如果我从 setText java 代码中删除电子邮件地址并运行该应用程序。电话号码变成蓝色并带有下划线,好像可以点击一样,但是当我点击它时,没有任何反应。

我怎样才能让它工作?

此外,我在清单文件和模拟器设备上授予了 CALL_PHONE 权限。

android textview android-phone-call

5
推荐指数
1
解决办法
2913
查看次数

Audiomanager扬声器不起作用

我正在通话时尝试启用扬声器:

final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);
Run Code Online (Sandbox Code Playgroud)

我试图检查setSpeakerphoneOn()音频管理器后,通过询问是否仍未打开扬声器isSpeakerphoneOn()

audioManager.isSpeakerphoneOn();
Run Code Online (Sandbox Code Playgroud)

在我的日志中,我可以看到一些我无法理解的错误:

E/AudioManager: Don't setBluetoothScoOn-PackageName: com.myapp.app  on = false
E/AudioManager: Don't setSpeakerphoneOn-PackageName: com.myapp.app  on = true
Run Code Online (Sandbox Code Playgroud)

我在论坛中找不到有关此错误的任何信息。

在以下设备上不起作用:中兴Z981,华为p9,我已经尝试过,并android.permission.MODIFY_AUDIO_SETTINGS获得了批准。

performance android android-audiomanager android-phone-call

3
推荐指数
2
解决办法
2766
查看次数

如何发出呼叫号码的通知?

我希望它pendingIntent在单击屏幕上显示“通知”的按钮后创建通知。因此,当用户单击通知时,它会拨打类似 021-1234567 的号码。我该怎么做呢?

我一直在网上寻求帮助,但似乎找不到任何与此相关的信息。

public void notifyPendingIntent(View view) {

    Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+ 0211234567));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0);

    // Build notification
    Notification notify = new Notification.Builder(this)
            .setContentTitle("Make this call")
            .setContentText("New call must be made to 021 123 4567")
            .setTicker("New Alert")
            .setContentIntent(pIntent).build();
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // hide the notification after its selected
    notify.flags |= Notification.FLAG_AUTO_CANCEL;

    notificationManager.notify(0, notify);
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经有了这个,但是当我按下按钮时,什么也没有发生。

我试过了,现在可以用了。感谢所有试图提供帮助的人。

public void notifyPendingIntent(View view) {

    NotificationCompat.Builder myNotification = new NotificationCompat.Builder(this) …
Run Code Online (Sandbox Code Playgroud)

notifications android android-intent android-phone-call

2
推荐指数
1
解决办法
5097
查看次数