android – 从首选项启动设置活动XML在2.x中运行,但在4.x中不运行

android – 从首选项启动设置活动XML在2.x中运行,但在4.x中不运行,第1张

概述我使用 the following technique将文本转语音设置添加到我应用的首选项屏幕: <Preference android:key="TTS Preferenes" android:title="TTS Settings" android:summary="A convenience shortcut instead of pressing HOME then Set 我使用 the following technique将文本转语音设置添加到我应用的首选项屏幕:

<Preference androID:key="TTS Preferenes"    androID:title="TTS Settings"    androID:summary="A convenIEnce shortcut instead of pressing HOME then Setting then scrolling down then pressing Text-to-Speech Settings">           <intent androID:targetPackage="com.androID.settings"    androID:targetClass="com.androID.settings.TextToSpeechSettings" />    </Preference>

它在AndroID 2.x中运行良好,但在AndroID 4.0.4中会产生异常:

E/AndroIDRuntime(2663): androID.content.ActivityNotFoundException:  Unable to find explicit activity class {com.androID.settings/com.androID.settings.TextToSpeechSettings};   have you declared this activity in your AndroIDManifest.xml?

为什么是这样?在AndroID 4(或3?)中发生什么变化使得这种技术不兼容?系统的TextToSpeechSettings首选项屏幕的名称是否已更改?

另外,我很确定与Manifest文件无关,但为了安全起见,我添加到Manifest中:

<activity androID:name="com.androID.settings.TextToSpeechSettings"            androID:label="Text-to-Speech Settings">  </activity>

并没有改变一件事.相同的ActivityNotFoundException问题.

在我寻找解释时,我找到了this thread,但它没有提到任何 *** 作系统版本的差异,所以我不确定它是否适用于此.

关于为什么以及如何解决这个问题的任何提示?

解决方法 看来确实这是一个ICS问题,因为 this answer建议使用此代码:

intent = new Intent();intent.setAction("com.androID.settings.TTS_SETTINGS");intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);this.startActivity(intent);
总结

以上是内存溢出为你收集整理的android – 从首选项启动设置活动XML在2.x中运行,但在4.x中不运行全部内容,希望文章能够帮你解决android – 从首选项启动设置活动XML在2.x中运行,但在4.x中不运行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1127264.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存