相关疑难解决方法(0)

从第二个sim打电话

我有一个双卡通Android手机.我正在使用此代码拨打电话:

private void callBack(String phone, Context context) {
        Intent callIntent = new Intent(Intent.ACTION_CALL)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        callIntent.setData(Uri.parse("tel:" + phone));
        context.startActivity(callIntent);

    }
Run Code Online (Sandbox Code Playgroud)

它工作正常.但它总是从sim1调用(最好是sim).如何从Sim2拨打电话?有没有办法处理双卡手机?

android phone-call dual-sim

19
推荐指数
2
解决办法
2万
查看次数

撤销权限android.permission.CALL_PHONE

我正在尝试以编程方式使用以下代码调用数字:

 String number = ("tel:" + numTxt.getText());
 Intent intent = new Intent(Intent.ACTION_CALL);
 intent.setData(Uri.parse(number));
 startActivity(intent);
Run Code Online (Sandbox Code Playgroud)

我在Manifest中设置了权限:

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

我正在使用真实设备进行测试和调试,它是带有Android M的Nexus 5,我的compileSdkVersion是23.我得到以下安全例外:

error: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity } from ProcessRecord{cbbd7c1 5228:com.dialerTest.DialerApp/u0a96} (pid=5228, uid=10096) with revoked permission android.permission.CALL_PHONE
Run Code Online (Sandbox Code Playgroud)

我在网络和这个社区搜索了类似的问答,但找不到答案.任何帮助将不胜感激.

android android-intent android-permissions

19
推荐指数
3
解决办法
3万
查看次数

如何在android中以编程方式进行调用

我想通过编程方式定期拨打/接听来自我的Android应用程序的测试,并从我的网络收集统计信息.所以我的应用程序会经常拨打一个号码,当电话接听时,应用程序将在几秒钟后终止呼叫.首先,我理解的代码可以使用.它将拨打和拨打我指定的号码,而不必触摸屏幕.

public class MainActivity extends AppCompatActivity {

int MY_PERMISSIONS_REQUEST_CALL_PHONE = 101;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    call();
}

private void call() {

    try {

        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:2125551212"));
        System.out.println("====before startActivity====");



        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) !=
                PackageManager.PERMISSION_GRANTED) {

            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.CALL_PHONE},
                    MY_PERMISSIONS_REQUEST_CALL_PHONE);

            return;
        }

        startActivity(callIntent);
        System.out.println("=====getcallActivity==="+getCallingActivity());


    } catch (ActivityNotFoundException e) {
        Log.e("helloAndroid","Call failed",e);
    }
}

}
Run Code Online (Sandbox Code Playgroud)

清单有这条线:

根据我的理解,ACTION_CALL应该拨打我提供的号码,而不必按下DIAL键.但是就像ACTION_DIAL一样,它在屏幕上显示数字,然后用户必须按DIAL键才能发出呼叫.ACTION_DIAL和ACTION_CALL之间没有区别吗?

在阅读了一些帖子后,我了解到需要用户拨打6.0以上的权限来拨打电话(我在上面的代码中使用过)

我的问题是,如果我使用Lollipop(5.0)操作系统,那么我可以在不拨号的情况下拨打电话吗?

android phone-call android-5.0-lollipop

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

如何在Android中按下按钮拨打号码?

我非常喜欢这个,我正在努力让它发挥作用.

当按下按钮时,我只想让拨号器打开并自动输入指定的号码.

到目前为止,我已经尝试了以下内容:

Button btn_call_us = (Button) findViewById(R.id.btn_call_us);
       btn_call_us.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:00000000"));
                startActivity(callIntent);

            }
        });
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

Button btn_call_us = (Button) findViewById(R.id.btn_call_us);
        btn_call_us.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                String phoneno="00000000";

                Intent i=new Intent(Intent.ACTION_CALL,Uri.parse(phoneno));
                startActivity(i);

            }
        });
Run Code Online (Sandbox Code Playgroud)

我已将权限ACTION_CALL添加到清单中.

每当我点击"呼叫"按钮时,应用程序强制关闭.

任何帮助将不胜感激.

谢谢!

java android phone-call

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