标签: android-phone-call

如何在Android中使用intent打电话?

我正在使用以下代码在Android中进行调用,但它给了我安全例外,请帮忙.

 posted_by = "111-333-222-4";

 String uri = "tel:" + posted_by.trim() ;
 Intent intent = new Intent(Intent.ACTION_CALL);
 intent.setData(Uri.parse(uri));
 startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

权限

 <uses-permission android:name="android.permission.CALL_PHONE" />
Run Code Online (Sandbox Code Playgroud)

例外

11-25 14:47:01.661: ERROR/AndroidRuntime(302): Uncaught handler: thread main exiting due to uncaught exception
11-25 14:47:01.681: ERROR/AndroidRuntime(302): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:111-333-222-4 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{43d32508 302:com.Finditnear/10026} (pid=302, uid=10026) requires android.permission.CALL_PHONE
11-25 14:47:01.681: ERROR/AndroidRuntime(302):     at android.os.Parcel.readException(Parcel.java:1218)
11-25 14:47:01.681: ERROR/AndroidRuntime(302):     at android.os.Parcel.readException(Parcel.java:1206)
11-25 14:47:01.681: ERROR/AndroidRuntime(302):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1214)
11-25 14:47:01.681: ERROR/AndroidRuntime(302):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1373)
11-25 14:47:01.681: ERROR/AndroidRuntime(302):     at android.app.Activity.startActivityForResult(Activity.java:2749) …
Run Code Online (Sandbox Code Playgroud)

android phone-call android-intent android-implicit-intent android-phone-call

307
推荐指数
15
解决办法
29万
查看次数

Android录制来电和去电

我想了解有没有办法在Android手机2.2及以上版本上记录来电和外拨电话?

客户希望记录他们对客户进行的代理的调用,以便以后可以用它来填写一些材料.而不是让客户端在通话时等待他们想要稍后再做.

这是可能的,我需要使用哪些API?

android android-phone-call call-recording

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

媒体录音机录制电话有时无法录制其他侧面语音

在我的应用程序中,有一个功能来记录语音呼叫,它的工作非常好.但是当测试(三星s7,s8)它不能很好地工作.该应用程序只能记录来电者的声音而不是另一端的声音.以下是我的代码检查请建议解决方案

MediaRecd = new MediaRecorder();
            MediaRecd.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL
            );

            MediaRecd.setAudioChannels(ConstantVariables.audioChannels);//monoRecording

   MediaRecd.setAudioEncodingBitRate(64);
            MediaRecd.setAudioSamplingRate(44100);


            MediaRecd.setOutputFormat(output_formats[pos]);//.mp3
            MediaRecd.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);//I already try with all possible CAMCORDER , MIC , Default etc etc but none was working
            MediaRecd.setOutputFile(Currentfilename);

            try {
                MediaRecd.prepare();
                MediaRecd.start();


            } catch (Exception e) {
                MediaRecd.reset();
                MediaRecd.release();
                MediaRecd = null;

            }
Run Code Online (Sandbox Code Playgroud)

请帮忙

android phone-call android-mediarecorder android-phone-call

13
推荐指数
1
解决办法
2760
查看次数

在LockState中通过PhoneScreen显示Toast

我们的目标是在发生呼号时展示祝酒词.当设备被锁定并发生接收呼叫时,这将不起作用.然后在" 锁定的全屏幕进入呼叫视图" 后面可以看到吐司.

我们尝试了不同的approches,结果相同:

  • PhoneCallListener/BroadCastReciver
  • 而不是吐司,使用一些新的Intent与一些标志(ShowOnLockScreen等)

允许:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Run Code Online (Sandbox Code Playgroud)

PhoneCallListener的设置:

public class PhoneCallDetector : PhoneStateListener
{
    public override void OnCallStateChanged(CallState state, string incomingNumber)
    {
        ShowToast(incomingNumber);
        base.OnCallStateChanged(state, incomingNumber);
    }


    private void ShowToast(string phonenumber)
    {
        Toast toast = Toast.MakeText(Application.Context, phonenumber, ToastLength.Long);
        toast.SetGravity(GravityFlags.Center, 0, 0);
        toast.Show();
    }
}
Run Code Online (Sandbox Code Playgroud)

我们知道一些可以通过" 锁定的全屏嵌入调用视图"成功显示toast的应用程序,但是它们是用java编写的......它们也没有做任何特殊的事情,然后Toast.MakeText(....).

编辑: => PhoneStateListener在后台生命.从服务开始.

服务如何开始?

Intent serviceStart = new Intent(context, typeof(PhoneCallService));
context.StartService(serviceStart);
Run Code Online (Sandbox Code Playgroud)

如何调用PhoneCallDetector?

 var phoneCallDetector = m_scope.Resolve<PhoneCallDetector>();
 var tm = (TelephonyManager)GetSystemService(TelephonyService);
 tm.Listen(phoneCallDetector, PhoneStateListenerFlags.CallState);
Run Code Online (Sandbox Code Playgroud)

谢谢你帮助我:-)

c# xamarin.android android-toast xamarin.forms android-phone-call

13
推荐指数
1
解决办法
213
查看次数

Android Device Monitor依赖于旧版Java SE 6运行时

对于Android Studio v2.2,不推荐使用DDMS,而选择Android Device Monitor.但是当我尝试打开监视器时,它没有打开,因为它依赖于遗留的Java SE 6运行时,这在我的Mac Os Sierra中缺失.这太疯狂了,不是吗?

我想尝试模拟传入的短信,从监视器到模拟器的电话.此监视器不适用于jdk 7/8.出路是什么?

android android-studio-2.2 android-sms android-monitor android-phone-call

10
推荐指数
1
解决办法
817
查看次数

调用RequestInterruptionFilter后电话不响铃

我目前正在开发一个可以改变设备环形模式的应用程序.为此,我创建了一个,NotificationListenerService并且从我的代码中我打电话requestInterruptionFilter来改变环模式.这里的一切都很棒!

现在,当我测试应用程序时,它出现了以下情况:我的手机上接到一个电话,在我的应用程序设置之后很短的时间,INTERRUPTION_FILTER_ALL但我的手机没有振铃.所以我在模拟器中尝试了相同的操作,我可以控制电话呼叫,它也会出现同样的奇怪行为:当INTERRUPTION_FILTER_ALARMS设置了ie 并且呼叫进来时我们设置INTERRUPTION_FILTER_ALL(在接听电话之前)电话没有响铃.

您是否有任何想法如何实现手机在这种情况下响铃?

编辑:我目前的代码如下:

public class NotificationService extends NotificationListenerService implements PhoneCallListener  {

    @Override
    public void onCreate() {
        super.onCreate();

        callReceiver = new CallReceiver(this);
        callReceiver.setListener(this);

        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_PHONE_STATE_CHANGED);

        registerReceiver(callReceiver, filter);
     }

     @Override
     public void onPhoneCallIncoming(String phoneNumber) {
         requestInterruptionFilter(INTERRUPTION_FILTER_ALL);
     }

     @Override
     public void onPhoneCallEnded() {
         Log.d("cilenco", "Phone call ended");
    }
}

public class CallReceiver extends BroadcastReceiver {

    public void setListener(PhoneCallListener listener) {
        this.listener = listener;
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android notification-listener android-phone-call

9
推荐指数
0
解决办法
112
查看次数

什么是phonestateintentreceiver.notifyPhoneCallState用于?

谁能告诉我有什么用phonestateintentreceiver.notifyPhoneCallState

android android-phone-call

8
推荐指数
1
解决办法
4720
查看次数

如何在 android 11 及以下版本中记录电话

我正在制作一个应用程序,我必须在其中记录用户的电话并转换他的声音以检查用户结束词并对这些结束词执行操作。我无法录制电话,如果有人知道如何录制电话,请帮助我。

提前致谢。

String out = new SimpleDateFormat("dd-MM-yyyy hh-mm-ss").format(new Date());
File sampleDir = new File(Environment.getExternalStorageDirectory(), "/Test");
if (!sampleDir.exists()) {
    sampleDir.mkdirs();
}
String file_name = "Record";
try {
    audiofile = File.createTempFile(file_name, ".amr", sampleDir);
} catch (IOException e) {
    e.printStackTrace();
}
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);

//                        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION);
recorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(audiofile.getAbsolutePath());
try {
    recorder.prepare();
} catch (IllegalStateException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
recorder.start();
Run Code Online (Sandbox Code Playgroud)

我已使用此代码录制语音通话,但对我不起作用。

java android phone-call programmatically android-phone-call

7
推荐指数
0
解决办法
54
查看次数

在牛轧糖中自动接听来电

有没有办法在没有root权限的情况下以编程方式应答Android 7.0中的来电?我尝试了以下方式接听来电。

 TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                  Class<?> c = Class.forName(tm.getClass().getName());
                  Method m = c.getDeclaredMethod("getITelephony");
                  m.setAccessible(true);
                  Object telephonyService = m.invoke(tm);
                  Class<?> telephonyServiceClass = Class.forName(telephonyService.getClass().getName());
                  Method endCallMethod = telephonyServiceClass.getDeclaredMethod("answerRingingCall");
                  endCallMethod.invoke(telephonyService);
Run Code Online (Sandbox Code Playgroud)

android call telephonymanager android-phone-call

6
推荐指数
1
解决办法
380
查看次数

PHONE_CALL权限在Dexter中无效

我在我的应用程序中实现了Dexter.它适用于CAMERA,EXTERNAL STORAGE和INTERNAL STORAGE许可.我想和Dexter一起使用PHONE_CALL许可.当我打电话给这样的电话时:

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + strNum));
startActivity(callIntent);
Run Code Online (Sandbox Code Playgroud)

然后startActivity显示警告Call requires permission which may be rejected by user: code should explicitly check to see if permission is available (with checkPermission) or explicitly handle a potential SecurityException less... (Ctrl+F1)

我不明白我实施了Dexter然后为什么startActivity要获得自我许可?

android android-intent android-permissions android-phone-call

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