我的問題看起來很愚蠢,但是我收到短信時會做一個簡單的代碼來製作Toast
,但無法看到我的祝酒詞。無法與廣播接收者敬酒,絕不打電話接收
我的Android清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.romain.assistantvocal" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<activity
android:name=".MyActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver class="com.example.romain.SMSReceiver" android:name=".SMSReceiver">
<intent-filter android:priority="100">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
在這裏,我的課SMSReceiver:
package com.example.romain.assistantvocal;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.telephony.gsm.SmsMessage;
import android.widget.Toast;
import java.util.Locale;
/**
* Created by romain on 26/09/2014.
*/
public class SMSReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context,"gg romstan",Toast.LENGTH_LONG).show();
}
}
預先感謝您爲您的回答。
嘗試增加''100 to like 6565' –
2014-09-26 13:57:21
remove'class =「com.example.romain.SMSReceiver」',不要聲明兩次 – njzk2 2014-09-26 14:41:16