我正在开发一个 android 应用程序,点击运行后,我解锁 AVD 并单击菜单加载我的应用程序,我立即收到以下消息:The application Pico TTS (process com.svox..pico) has stopped unexpectedly. Please try again
这是我的AndroidManifest.xml
:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="true">
<activity android:name=".MPActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这些是来自我的 logcat 的消息:
10-09 13:01:14.796: I/TextToSpeech.java(1861): initTts() successfully bound to service
10-09 13:01:16.916: E/ActivityThread(1861): Activity com.kelamrsan.MPActivity has leaked ServiceConnection android.speech.tts.TextToSpeech$1@4051d710 that was originally bound here
10-09 13:01:16.916: E/ActivityThread(1861): android.app.ServiceConnectionLeaked: Activity com.kelamrsan.MPActivity has leaked ServiceConnection android.speech.tts.TextToSpeech$1@4051d710 that was originally bound here
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:938)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:833)
10-09 13:01:16.916: E/ActivityThread(1861): at android.content.ContextWrapper.bindService(ContextWrapper.java:347)
10-09 13:01:16.916: E/ActivityThread(1861): at android.speech.tts.TextToSpeech.initTts(TextToSpeech.java:467)
10-09 13:01:16.916: E/ActivityThread(1861): at android.speech.tts.TextToSpeech.<init>(TextToSpeech.java:433)
10-09 13:01:16.916: E/ActivityThread(1861): at com.kelamrsan.MPActivity.onCreate(MPActivity.java:47)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-09 13:01:16.916: E/ActivityThread(1861): at android.os.Handler.dispatchMessage(Handler.java:99)
10-09 13:01:16.916: E/ActivityThread(1861): at android.os.Looper.loop(Looper.java:130)
10-09 13:01:16.916: E/ActivityThread(1861): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-09 13:01:16.916: E/ActivityThread(1861): at java.lang.reflect.Method.invokeNative(Native Method)
10-09 13:01:16.916: E/ActivityThread(1861): at java.lang.reflect.Method.invoke(Method.java:507)
10-09 13:01:16.916: E/ActivityThread(1861): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-09 13:01:16.916: E/ActivityThread(1861): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-09 13:01:16.916: E/ActivityThread(1861): at dalvik.system.NativeStart.main(Native Method)
这是我的onCreate
:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonLoadImage = (Button)findViewById(R.id.loadimage);
textView = (TextView) findViewById(R.id.textView);
textViewCol = (TextView) findViewById(R.id.textViewColor);
targetImage = (ImageView) findViewById(R.id.targetimage);
textViewVal = (TextView) findViewById(R.id.textViewValue);
mTts = new TextToSpeech(this, new OnInitListener() {
@Override
public void onInit(int status) {
TTSInitialized = true;
}
});
Intent installIntent = new Intent();
installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
buttonLoadImage.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}});
}
那你觉得问题出在哪里?!