几天来,我一直在努力解决这个问题,并决定寻求帮助。我正在尝试让我的 Android 应用程序响应收到的彩信。这是我的主要内容:
private IntentFilter filter = new IntentFilter(MMSReceiver.MMS_RECEIVED);
private MMSReceiver mmsReceiver = new MMSReceiver();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
registerReceiver(mmsReceiver, filter);
...
}
我还有一个 MMSReceiver 类:
public class MMSReceiver extends BroadcastReceiver {
public static final String MMS_RECEIVED = "android.provider.Telephony.MMS_RECEIVED";
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(MMS_RECEIVED)){
System.out.println("b:mms received");
}
}
在看到另一个问题的建议后,我还尝试制作字符串“android.provider.Telephony.WAP_PUSH_RECEIVED”。此代码适用于 sms,因此它必须是特定于 mms 的。这是我第一次在这里发帖,所以如果我遗漏了什么,请告诉我。