gpt4 book ai didi

android - 无法从传入消息中获取广播接收

转载 作者:行者123 更新时间:2023-11-30 04:44:44 25 4
gpt4 key购买 nike

我在下面的 AndroidManifest.xml 中声明了一个 BroadcastReceiver,但我从未收到 SMS_RECEIVED 广播。知道发生了什么吗?

这是BroadcastReceiver:

public class SMSReceiver1 extends BroadcastReceiver 
{
private static final String LOG_TAG = "Thiri The Wut Yee";

private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";

public void onReceive(Context context, Intent intent)
{
Log.i(LOG_TAG, "Receive ");
Toast.makeText(context, "RECEIVED", Toast.LENGTH_LONG).show();
}
}

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android_programmers_guide.SMSReceiver1"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<receiver android:name=".SMSReceiver1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>

最佳答案

您的 list 中是否有此权限?

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

关于android - 无法从传入消息中获取广播接收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5268712/

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