當前位置:首頁 » 安卓系統 » android打電話代碼

android打電話代碼

發布時間: 2023-07-14 18:45:14

① Android調用撥打電話和發送簡訊

撥打電話常見兩種方法

1:直接撥打了你所輸入的號碼

2:去到了撥號界面

這種方式的特點就是,去到了撥號界面,但是實際的撥號是由用戶點擊實現的。

記得加入打電話的許可權
<uses-permission android:name="android.permission.CALL_PHONE" />

發送簡訊也可以直接跳到發送簡訊頁面也可以直接發送簡訊內容

編輯發送簡訊

1.編輯指定發送人和內內容:

2.編輯簡訊並發送

② 在androidstudio實現打電話功能真的會打出去嗎

在androidstudio實現打電話功能真的會打出去。
1、新建工程後,編輯界面。
2、點擊圖像按鈕時其實是啟動了另外一個activity。
3、編輯MainActivity。
4、添加許可權。
5、安卓6以上需要額外添加一個許可權申請。
6、即可實現效果。

③ 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跟蹤。

④ android如何實現後台打電話

第一種方法,撥打電話跳轉到撥號界面。源代碼如下:
?

1
2
3
4

Intent intent = new Intent(Intent.ACTION_DIAL);
Uri data = Uri.parse("tel:" + "135xxxxxxxx");
intent.setData(data);

⑤ android 怎麼用一個模擬器給另一個模擬器打電話

打開兩個模擬器,在其中一個直接撥號,比如5554給5556撥號,就直接撥5556就好了。

⑥ android開發怎麼撥打電話

無許可權版(彈出撥號界面並自動輸入電話號碼,用戶選擇是否撥號):

importandroid.content.Context;
importandroid.content.Intent;
importandroid.net.Uri;
publicvoidCall(StringNum,Contextc){
if(Num!=null&&Num.length()>0){
Intentitt=newIntent(Intent.ACTION_DIAL,Uri.parse("tel:"+Num));
itt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(itt);
}
}

許可權版(彈出撥號界面,自動輸入電話號碼並立刻撥號,在部分系統中會觸發安全警告):

<!---許可權--->
<uses-permissionandroid:name="android.permission.CALL_PHONE"/>
importandroid.content.Context;
importandroid.content.Intent;
importandroid.net.Uri;
publicvoidCall(StringNum,Contextc){
if(Num!=null&&Num.length()>0){
Intentitt=newIntent(Intent.ACTION_CALL,Uri.parse("tel:"+Num));
itt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(itt);
}
}

⑦ 如何向Android模擬器打電話

一、布局,拖一個框用來輸入電話號碼,一個按扭撥號
二、打電話的許可權添加進來
<uses-permission android:name="android.permission.CALL_PHONE"/>
三、寫撥號的點擊事件
Activity:
public class DialerAction extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button =(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener(){
publicvoid onClick(View v) {
EditTexteditText = (EditText)findViewById(R.id.mobile);
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ editText.getText()));
DialerAction.this.startActivity(intent);
}
});
}
}
四,輸入另一個模擬器,例如5554 5556之類的號碼就可以打電話了

熱點內容
python時間毫秒數 發布:2025-02-05 20:51:32 瀏覽:329
clash安卓如何切換節點 發布:2025-02-05 20:48:20 瀏覽:889
怎樣能用到方舟編譯器 發布:2025-02-05 20:47:04 瀏覽:366
資料庫的演算法 發布:2025-02-05 20:25:32 瀏覽:859
微信解壓異常 發布:2025-02-05 20:24:39 瀏覽:493
linux0位元組文件夾 發布:2025-02-05 20:23:07 瀏覽:652
專題的腳本怎麼寫 發布:2025-02-05 20:19:18 瀏覽:923
獨立站買什麼伺服器 發布:2025-02-05 20:13:24 瀏覽:296
android鬧鍾設置 發布:2025-02-05 20:12:29 瀏覽:955
計算機代碼經典編程 發布:2025-02-05 19:25:09 瀏覽:757