Questions tagged «incoming-call»

10
如何在Android设备中检测来电?
我正在尝试制作一个类似的应用程序,当电话打来时,我想检测该号码。以下是我尝试过的方法,但未检测到来电。 我想MainActivity在后台运行我,该怎么办? 我已经在manifest文件中给予了许可。 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 清单中还应该提供其他内容吗? public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test_layout); } public class myPhoneStateChangeListener extends PhoneStateListener { @Override public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); if (state == TelephonyManager.CALL_STATE_RINGING) { String phoneNumber = incomingNumber; } } } }

10
如何在Android 5.0(Lollipop)中以编程方式接听来电?
当我尝试为来电创建自定义屏幕时,我试图以编程方式接听来电。我正在使用以下代码,但在Android 5.0中不起作用。 // Simulate a press of the headset button to pick up the call Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON); buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK)); context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED"); // froyo and beyond trigger on buttonUp instead of buttonDown Intent buttonUp = new Intent(Intent.ACTION_MEDIA_BUTTON); buttonUp.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK)); context.sendOrderedBroadcast(buttonUp, "android.permission.CALL_PRIVILEGED");

5
如何在Android中阻止通话
我想阻止来自几个号码的呼叫,为此,我想编写自己的应用程序。那么我应该使用哪些API? 基本上,我想在打来电话时得到通知,如果要阻止,我想比较号码,我想切断电话或将其静音,或者尽可能将其静音并记录下来。

2
在Multi-Sim设备中检测来电的目标SimCard
我读了很多文章并尝试了许多解决方案,但是所有文章的共同点是它们都已过时,至少我找不到能在较新版本的Android上运行的解决方案。 发布1,结果: intent.getExtras().getInt("simId", -1)总是返回-1 发布2,结果:intent.getExtras().getInt("slot", -1)总是返回-1 发表3,结果: String[] array = new String[]{ "extra_asus_dial_use_dualsim", "com.android.phone.extra.slot", "slot", "simslot", "sim_slot", "subscription", "Subscription", "phone", "com.android.phone.DialingMode", "simSlot", "slot_id", "simId", "simnum", "phone_type", "slotId", "slotIdx" }; for (String item : array) { Log.i(TAG, "Sim Card - " + item + " -----> " + intent.getExtras().getInt(item)); } 日志: …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.