我正在做一个阻止某些电话的应用程序。我有一个广播接收器来解决此问题。但是,当我(手动或按系统)杀死我的应用程序时,接收器不起作用。
我以为我需要一种执行广播接收器或阻止其自身调用的服务。我该怎么办?
谢谢你的优势。
编辑 我的接收器课程:
Dim N As Long
Dim wsName As String
For N = 1 To ThisWorkbook.Sheets.Count
wsName = ThisWorkbook.Worksheets(N).Name
If Len(wsName) = 3 Then
'command
Call blank
Call hide
Else 'do nothing
End If
Next N
Sub blank()
Range("T2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]<>"""",RC[-2]="""",""FALSE"")"
Range("T2").Select
Selection.AutoFill Destination:=Range("T2:T6999")
End Sub
Sub hide()
Columns("T:T").Select
Selection.EntireColumn.Hidden = True
End Sub
我的接收者清单:
public class IncomingCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
ITelephony telephonyService;
try {
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Method m = tm.getClass().getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(tm);
if ((number != null)) {
telephonyService.endCall();
Toast.makeText(context, "Ending the call from: " + number, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(context, "Ring " + number, Toast.LENGTH_SHORT).show();
}
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
Toast.makeText(context, "Answered " + number, Toast.LENGTH_SHORT).show();
}
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)) {
Toast.makeText(context, "Idle " + number, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}