當前位置:首頁 » 安卓系統 » android開發撥號

android開發撥號

發布時間: 2022-04-27 18:05:38

Ⅰ Android實現撥號功能

請檢查你這個activity的permission,有沒有加上以下的設置。
在AndroidManifest.xml裡面添加。

<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

另外幫你貼下android自帶撥號程序的核心部分,請自己參照下吧~~
public class OutgoingCallBroadcaster extends Activity {

private static final String PERMISSION = android.Manifest.permission.PROCESS_OUTGOING_CALLS;
private static final String TAG = "OutgoingCallBroadcaster";
private static final boolean LOGV = true;//Config.LOGV;

public static final String EXTRA_ALREADY_CALLED = "android.phone.extra.ALREADY_CALLED";
public static final String EXTRA_ORIGINAL_URI = "android.phone.extra.ORIGINAL_URI";

private Phone mPhone;

@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);

mPhone = PhoneApp.getInstance().phone;

Intent intent = getIntent();
if (LOGV) Log.v(TAG, "onCreate: Got intent " + intent + ".");

String action = intent.getAction();
String number = PhoneNumberUtils.getNumberFromIntent(intent, this);
if (number != null) {
number = PhoneNumberUtils.stripSeparators(number);
}
final boolean emergencyNumber =
(number != null) && PhoneNumberUtils.isEmergencyNumber(number);

boolean callNow;

if (getClass().getName().equals(intent.getComponent().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 (!Intent.ACTION_CALL.equals(intent.getAction())) {
Log.w(TAG, "Attempt to deliver non-CALL action; forcing to CALL");
intent.setAction(Intent.ACTION_CALL);
}
}

/* Change CALL_PRIVILEGED into CALL or CALL_EMERGENCY as needed. */
if (Intent.ACTION_CALL_PRIVILEGED.equals(action)) {
action = emergencyNumber
? Intent.ACTION_CALL_EMERGENCY
: Intent.ACTION_CALL;
intent.setAction(action);
}

if (Intent.ACTION_CALL.equals(action)) {
if (emergencyNumber) {
finish();
return;
}
callNow = false;
} else if (Intent.ACTION_CALL_EMERGENCY.equals(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.
PhoneApp.getInstance().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 || TextUtils.isEmpty(number)) callNow = true;

if (callNow) {
intent.setClass(this, InCallScreen.class);
startActivity(intent);
}

Intent broadcastIntent = new Intent(Intent.ACTION_NEW_OUTGOING_CALL);
if (number != null) broadcastIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, number);
broadcastIntent.putExtra(EXTRA_ALREADY_CALLED, callNow);
broadcastIntent.putExtra(EXTRA_ORIGINAL_URI, intent.getData().toString());
broadcastIntent.putExtra(EXTRA_INTENT_FROM_BT_HANDSFREE,
intent.getBooleanExtra(OutgoingCallBroadcaster.EXTRA_INTENT_FROM_BT_HANDSFREE, false));

if (LOGV) Log.v(TAG, "Broadcasting intent " + broadcastIntent + ".");
sendOrderedBroadcast(broadcastIntent, PERMISSION, null, null,
Activity.RESULT_OK, number, null);

finish();
}

}

Ⅱ 安卓開發撥號器出錯閃退

你好。你的手機內存不足。清理一下把。望採納 是的 我也喜歡2011版的安卓系統4.0以上不能用。會閃退,不過有修改版的,修改的不好不穩定,你可以到網路上找修改版的

Ⅲ android開發怎麼實現撥號拼音檢索聯系人的功能

不能~一般只能開頭那個字的大寫
「張小軍」
就輸入Z就檢測出來選項選擇

Ⅳ Android開發,設計如下一個手機撥號界面,要求使用動態添加按鈕以及綁定響應函數。

童鞋,你上的是劉寧的專選吧~

Ⅳ android開發怎麼撥打電話

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

java">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);
}
}

Ⅵ 安卓開發 如何替換安卓系統默認的撥號程序

這個怎麼可能會默認打開某個撥號程序呢?

這是個系統撥號inten如果某個界面聲明接收這個intent
就可以打開這個界面
如果一個手機有多個接收撥打電話的intent且沒有選擇默認程序的情況下會出現選擇框,如果已經選擇了默認程序可以直接打開默認程序
正常代碼不可能直接修改系統的設置,除非你獲得root許可權在修改內存數據去.
或者讓用戶點擊你的按鈕那樣才能行

Ⅶ 在android開發中,如何實現一鍵撥號。是用「intent」然後調用資料庫中的號碼來實現嗎

是先獲得存儲的號碼,然後把號碼作為Intent中的參數,啟動撥號應用來實現的一鍵撥號。

Ⅷ android開發,如何啟動自己的撥號面板

有action屬性設置。不需要你關鍵的

Ⅸ android 開發製作通訊錄,怎麼實現按撥號鍵對當前聯系人撥號

通訊錄是用listview做的嗎?如果是那麼用撥號鍵的button對象setTag吧電話號存起來,然後在監聽事件內取出來,這樣就能保證每一行的號碼都是相對應的了。例如。。
btn.setTag(p.telephone);
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + v.getTag()));
startActivity(intent);
}
});

Ⅹ Android開發簡單撥號器實現

public class MainActivity extends ActionBarActivity {

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

if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_main, container,
false);

Button mbutton = (Button)rootView.findViewById(R.id.button1);

mbutton.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {

EditText mEditText = (EditText)rootView.findViewById(R.id.edittext);
String number = mEditText.getText().toString();
Intent intent = new Intent();
intent.setAction("android.intent.action.CALL");
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);

TextView mtext = (TextView)rootView.findViewById(R.id.text2);
mtext.setText("按鈕事件啟動了");

}
} );

return rootView;
}
}

}

這是我使用4.4版本下開發的一個電話撥號器的java代碼,你看看,希望能幫到你,電話啟動代碼寫到PlaceholderFragment里

熱點內容
安卓手機卸載更新什麼意思 發布:2024-04-24 19:29:35 瀏覽:227
文件des加密 發布:2024-04-24 19:24:20 瀏覽:704
魔獸世界data文件夾 發布:2024-04-24 19:24:13 瀏覽:213
蘋果手機怎麼清空緩存 發布:2024-04-24 19:23:38 瀏覽:892
微信密碼沒有手機號如何找回 發布:2024-04-24 19:18:20 瀏覽:874
微雲解析源碼 發布:2024-04-24 19:13:58 瀏覽:791
紙張記錄存儲 發布:2024-04-24 19:00:35 瀏覽:801
存儲結構中定義一個集合 發布:2024-04-24 18:52:05 瀏覽:427
搜狗網址存儲的密碼在哪裡查看 發布:2024-04-24 18:52:03 瀏覽:917
抖音搶福袋腳本最新 發布:2024-04-24 18:52:00 瀏覽:702