请检查你这个activity的permission,有没有加上以下的设置。
在AndroidManifestxml里面添加。
<uses-permission android:name="androidpermissionBROADCAST_STICKY" />
<uses-permission android:name="androidpermissionCALL_PHONE" />
<uses-permission android:name="androidpermissionCALL_PRIVILEGED" />
<uses-permission android:name="androidpermissionINTERNET" />
<uses-permission android:name="androidpermissionPROCESS_OUTGOING_CALLS" />
另外帮你贴下android自带拨号程序的核心部分,请自己参照下吧~~
public class OutgoingCallBroadcaster extends Activity {
private static final String PERMISSION = androidManifestpermissionPROCESS_OUTGOING_CALLS;
private static final String TAG = "OutgoingCallBroadcaster";
private static final boolean LOGV = true;//ConfigLOGV;
public static final String EXTRA_ALREADY_CALLED = "androidphoneextraALREADY_CALLED";
public static final String EXTRA_ORIGINAL_URI = "androidphoneextraORIGINAL_URI";
private Phone mPhone;
@Override
protected void onCreate(Bundle icicle) {
superonCreate(icicle);
mPhone = PhoneAppgetInstance()phone;
Intent intent = getIntent();
if (LOGV) Logv(TAG, "onCreate: Got intent " + intent + "");
String action = intentgetAction();
String number = PhoneNumberUtilsgetNumberFromIntent(intent, this);
if (number != null) {
number = PhoneNumberUtilsstripSeparators(number);
}
final boolean emergencyNumber =
(number != null) && PhoneNumberUtilsisEmergencyNumber(number);
boolean callNow;
if (getClass()getName()equals(intentgetComponent()getClassName())) {
// If we were launched directly from the OutgoingCallBroadcaster,
// not one of its more privileged aliases, then make sure that
// only the non-privileged actions are allowed
if (!IntentACTION_CALLequals(intentgetAction())) {
Logw(TAG, "Attempt to deliver non-CALL action; forcing to CALL");
intentsetAction(IntentACTION_CALL);
}
}
/ Change CALL_PRIVILEGED into CALL or CALL_EMERGENCY as needed /
if (IntentACTION_CALL_PRIVILEGEDequals(action)) {
action = emergencyNumber
IntentACTION_CALL_EMERGENCY
: IntentACTION_CALL;
intentsetAction(action);
}
if (IntentACTION_CALLequals(action)) {
if (emergencyNumber) {
finish();
return;
}
callNow = false;
} else if (IntentACTION_CALL_EMERGENCYequals(action)) {
if (!emergencyNumber) {
finish();
return;
}
callNow = true;
} else {
finish();
return;
}
// Make sure the screen is turned on This is probably the right
// thing to do, and more importantly it works around an issue in the
// activity manager where we will not launch activities consistently
// when the screen is off (since it is trying to keep them paused
// and has issues)
//
// Also, this ensures the device stays awake while doing the following
// broadcast; technically we should be holding a wake lock here
// as well
PhoneAppgetInstance()wakeUpScreen();
/ If number is null, we're probably trying to call a non-existent voicemail number or
something else fishy Whatever the problem, there's no number, so there's no point
in allowing apps to modify the number /
if (number == null || TextUtilsisEmpty(number)) callNow = true;
if (callNow) {
intentsetClass(this, InCallScreenclass);
startActivity(intent);
}
Intent broadcastIntent = new Intent(IntentACTION_NEW_OUTGOING_CALL);
if (number != null) broadcastIntentputExtra(IntentEXTRA_PHONE_NUMBER, number);
broadcastIntentputExtra(EXTRA_ALREADY_CALLED, callNow);
broadcastIntentputExtra(EXTRA_ORIGINAL_URI, intentgetData()toString());
broadcastIntentputExtra(EXTRA_INTENT_FROM_BT_HANDSFREE,
intentgetBooleanExtra(OutgoingCallBroadcasterEXTRA_INTENT_FROM_BT_HANDSFREE, false));
if (LOGV) Logv(TAG, "Broadcasting intent " + broadcastIntent + "");
sendOrderedBroadcast(broadcastIntent, PERMISSION, null, null,
ActivityRESULT_OK, number, null);
finish();
}
}
拨号上网的方法如下:
1确保你的调制解调器已经安装了正确的驱动程序。
2电话线没有问题,打个电话试一下就知道了。
3如果以上两项都没有问题了,现在打开“网上邻居”属性窗口,在窗口左侧选择“创建一个新的连接”,打开“新建连接向导”对话框。
4在这个对话框中点击“下一步”,d出“网络连接类型”对话框。
5在这个窗口中选择“连接到Internet”这一项,点击“下一步”,d出“准备好”对话框。
6在这个窗口中选择“手动设置我的连接”,点击“下一下”,d出“Internet连接”对话框。
7在这个对话框中选择“用拨号调制解调器连接”,点击“下一步”,d出“连接名”对话框。
8在这个窗口中“ISP名称”处可以随便输入,比如“拨号上网”,然后点击“下一步”,d出“要拨的电话号码”对话框。
9此处是最关键的一步,“电话号码”处输入一定要注意,如果你用的是普通的电话,要拨号的话,应该这样输入“16900”,如果是201电话卡上网的话,该这样“201,XXXXXXXX#,YYYYYY#,16900”输入,其中XX表示你的201卡号,YY表示你的201电话卡的密码,这一步一定要很仔细,因为它是你拨号成功的关键一步,输好了电话号码之后,点击“下一步”,d出“Internet帐户信息”对话框。
10在这个窗口中,“用户名”处输入“16900”,“密码”处输入“16900”,“确认密码”一样也是“16900”,点击“下一步”,d出“完成连接向导”对话框。
11选中“在我的桌面上添加一个到此连接的快捷方式”前的复选框,点击“完成”按钮。
12双击在桌面上建立的快捷方式,在打开的窗口中输入用户名和密码,这两项都是“16900”,然后开始拨号,如果拨号正常的话,先出现“正在拨号”这样一个提示,接着“正在连接到”,然后“验证您的用户名和密码”,然后“正在登陆网络”,最后,“已经连接”。
注:1如果你的第12步,有问题的话,请多试几次,因为拨号上网有时拨不上去是很正常的, 另外,看看你的猫是不是有问题。
2普通电话拨号上网是比较贵的,河南这边一个小时要3元多,201电话卡一个小时12元。
以上就是关于Android实现拨号功能全部的内容,包括:Android实现拨号功能、100分!把电话拨号上网的 *** 作步骤写来!详细见补充、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)