0
A
回答
1
先廣播接收器的子類
public class CallReceiver extends BroadcastReceiver {
在manifest.xml文件添加它
<receiver android:name="com.myapp.calldropper.CallReceiver" > <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver>
在默認
Intent callRejectIntent = new Intent(context, MainActivity.class);
callRejectIntent.putExtra("MOBILE_NUMBER", mobNum);
callRejectIntent.putExtra("REJECT_COUNT", rejectCount);
callRejectIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(callRejectIntent);
再掀活動屏幕的活動將在默認的情況下啓動。現在您可以響應來自您的活動的接聽電話,您可以拒絕呼叫。
,因爲這會生成一個名爲com.android.internal.telephony
的單獨包,並在此創建一個名爲ITelephony.aidl
的簡單文本文件。該文件將包含以下
package com.android.internal.telephony;
import android.os.Bundle;
interface ITelephony {
boolean endCall();
void dial(String number);
void answerRingingCall();
}
中添加代碼的onCreate
TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
try {
// "cheat" with Java reflection to gain access to TelephonyManager's ITelephony getter
Class<?> c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(tm);
} catch (Exception e) {
e.printStackTrace();
}
現在你可以通過調用以下功能
private void ignoreCall() {
try {
// telephonyService.silenceRinger();
telephonyService.endCall();
} catch (RemoteException e) {
e.printStackTrace();
}
moveTaskToBack(true);
finish();
}
相關問題
- 1. 停止收聽自己的活動?
- 2. 自動鏈接呼叫活動:Android
- 3. 在Android的呼叫者屏幕上的自定義屏幕
- 4. 呼叫後停止收音
- 5. Android:自定義呼叫屏幕
- 6. Android:在電話呼叫期間停止Widget的MediaPlayer活動
- 7. 在屏幕活動後停止動畫
- 8. 當屏幕上顯示對話框活動時,原生呼叫屏幕動畫停止
- 9. 在Android中發起呼叫
- 10. 如何停止自動AJAX呼叫?
- 11. FreePBX:記錄自動發起的呼叫
- 12. 屏幕上的觸發呼叫關機?
- 13. Android中的呼叫屏幕顯示AlertDialog
- 14. 防止通過接口攔截呼叫
- 15. 通過意向發起SIP呼叫
- 16. 無法通過活動呼叫服務
- 17. 查看呼叫器結束後通過意向呼叫活動
- 18. 在通知呼叫接收機的PendingIntent
- 19. didUpdateToLocation停止呼叫
- 20. 在接收SIP呼叫時在BroadcastReceiver上啓動活動
- 21. C2DM廣播接收機在一段時間後停止呼叫
- 22. 如何在android上停止全屏幕默認活動?
- 23. 標準呼叫屏幕上的活動窗口 - 啓用按鈕
- 24. 短信接收的廣播接收機在Android中的未接呼叫時發出消息呼叫
- 25. 最小化默認呼叫屏幕並在Outgoingcall上打開活動
- 26. 強制停止會使app的接收器不被呼叫?
- 27. 在Android中,如何顯示我自己的傳出呼叫活動?
- 28. 呼叫自己的方法
- 29. jQuery動畫在呼叫停止並重新啓動後減速
- 30. 停止目前的活動,並通過其他活動
轉到此鏈接拒絕來電:HTTP://計算器。 com/questions/10069667/how-to-call-an-activity-when-getting-incoming-call –
這是一個很好的鏈接,但我的問題是我想停止默認的一個。 – umesh
我用另一種解決方案解決了這個問題,並用我的理解發布了這個問題的答案。 – umesh