在我的应用程序中,我有两个注册了android.provider.Telephony.SMS_RECEIVED
的广播接收器我希望其中一个始终在后台运行(解密),其中一个仅在单击按钮时才处于活动状态(DrivingMode) 。
DrivingMode广播接收器有speakSMS()
导致它崩溃。或者BR被触发就好了。
我做了一些根本错误的事情吗?
这是我的LogCat:
抱歉,我无法将其保存到.TXT文件中并将其粘贴到此处:(
这是DrivingMode.java:
package com.example.callandmessagemanager;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
public class DrivingMode extends Activity {
private static TextToSpeech myTts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.message_m);
myTts = new TextToSpeech(this,ttsInitListener);
}
private TextToSpeech.OnInitListener ttsInitListener=new TextToSpeech.OnInitListener() {
@Override
public void onInit(int version) {
// myTts.speak(""+o, 0 ,null);
}
};
public static void speakSMS(String sms)
{
myTts.speak(sms,0,null);
}
}