android打电话界面
❶ 在androidstudio实现打电话功能真的会打出去吗
在androidstudio实现打电话功能真的会打出去。
1、新建工程后,编辑界面。
2、点击图像按钮时其实是启动了另外一个activity。
3、编辑MainActivity。
4、添加权限。
5、安卓6以上需要额外添加一个权限申请。
6、即可实现效果。
❷ Android 跳转到拨号界面如何自动填写手机号,但是不自动拨出
1、跳转到拨号界面,代码如下:
1)直接拨打
java">IntentintentPhone=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+phoneNumber));
startActivity(intentPhone);
2)跳转到拨号界面
Intentintent=newIntent(Intent.ACTION_DIAL,Uri.parse("tel:"+phoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
2、跳转到联系人页面,使用一下代码:
IntentintentPhone=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+phoneNumber));
startActivity(intentPhone);
❸ 100分 Android怎么调用打电话而不显示系统的通话界面
1、 用反射调用 “com.android.internal.telephony.PhoneFactory”,“com.android.internal.telephony.CallManager”,“com.android.internal.telephony.Phone”中的方法。
代码如下:
public void Call(String number, Context context) {
try {
final Class<?> phoneFactoryClass = Class.forName("com.android.internal.telephony.PhoneFactory");
Method makeDefaultPhonesMethod = phoneFactoryClass.getDeclaredMethod("makeDefaultPhones", Context.class);
makeDefaultPhonesMethod.invoke(null, context);
Method getDefaultPhone = phoneFactoryClass.getDeclaredMethod("getDefaultPhone");
Object phone = getDefaultPhone.invoke(getDefaultPhone);
final Class<?> callManagerClass = Class.forName("com.android.internal.telephony.CallManager");
Method getInstanceMethod = callManagerClass.getDeclaredMethod("getInstance");
Object callManager = getInstanceMethod.invoke(getInstanceMethod);
final Class<?> phoneClass = Class.forName("com.android.internal.telephony.Phone");
Method registerPhoneMethod = callManagerClass.getDeclaredMethod("registerPhone", phoneClass);
registerPhoneMethod.invoke(callManager, phone);
Method maybeGetMethod = callManagerClass.getDeclaredMethod("getDefaultPhone");
Object phone1 = maybeGetMethod.invoke(callManager);
Method dial = phoneClass.getDeclaredMethod("dial", String.class);
dial.invoke(phone1, number);
} catch (ClassNotFoundException e) {
String string = e.getCause().toString();
Log.e("CallTest" ,string);
} catch (Exception e) {
String string = e.getCause().toString();
Log.e("CallTest" ,string);
}
}
2、在manifest中加如下权限
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.callphone"
android:sharedUserId="android.uid.system"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name= "andoird.permission.CALL_PHONE"/>
<uses-permission android:name= "andoird.permission.CALL_PRIVILEGED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL"/>
3、将生成的apk用系统签名,不同的OS有不同的签名,例如我用的是
java -jar signapk.jar platform.x509.pem platform.pk8 Callphone_unsigned.apk Callphone_signed.apk。其中platform.x509.pem platform.pk8在不同的OS中不同。
备注:用sharedUserId和系统签名后,程序才有权限运行。同理,程序不能调试,只能log跟踪。