首页 > 移动平台 > 详细

双卡手机怎么指定SIM卡打电话

时间:2014-07-07 10:34:07      阅读:348      评论:0      收藏:0      [点我收藏+]

双卡手机如何指定SIM卡打电话

package com.example.dualsimtest;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {
    public static final String[] dualSimTypes = { "subscription", "Subscription", 
        "com.android.phone.extra.slot", 
        "phone", "com.android.phone.DialingMode", 
        "simId", "simnum", "phone_type", 
        "simSlot" };
    EditText inputV;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        inputV = (EditText) findViewById(R.id.input);
        
        findViewById(R.id.call).setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                String number = inputV.getText().toString().trim();
               if (number.equals("")) { 
                   Toast.makeText(MainActivity.this, "输入号码不恩为空", 1500).show();
               } else {
                   call(number); 
               }
            }
        });
    }
    
    
    private void call(String phone) {
        Intent callIntent = new Intent(Intent.ACTION_CALL)
                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        callIntent.setData(Uri.parse("tel:" + phone));
        for (int i=0; i < dualSimTypes.length; i++) {
            callIntent.putExtra(dualSimTypes[i], 2);
        }
        this.startActivity(callIntent);
    }
    
}

双卡手机怎么指定SIM卡打电话,布布扣,bubuko.com

双卡手机怎么指定SIM卡打电话

原文:http://www.cnblogs.com/kobe8/p/3820474.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!