gpt4 book ai didi

Android 电话调用接收器不起作用

转载 作者:行者123 更新时间:2023-11-29 00:37:35 25 4
gpt4 key购买 nike

我想测试处理电话,所以我做了一个小应用程序,它应该在来电/去电上写一个日志。这是广播接收器:第一:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class IncomingCallReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

Log.d("DEBUGING", "INCOMING CALL DETECTED !!");

}
}

第二个:

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class OutgoingCallReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

Log.d("DEBUGING", "OUTGOING CALL DETECTED !!");

}
}

最后是 list

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.callrec"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name=".IncomingCallReceiver" >
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
<receiver android:name=".OutgoingCallReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
</application>

问题是我的接收者从来没有被叫过....我不知道为什么,有人能帮忙吗?

最佳答案

显然从 3.1+ 开始,只有在用户对您的 Activity 进行了至少一次操作后,您的接收器才会开始工作,因此没有 Activity 的我的应用程序将无法工作

关于Android 电话调用接收器不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11654208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com