android应用程序在哪找,找不到应用程序的错误android
长期以来,我试图开发一个应用程序,通过语音通知用户任何传入消息,我有三个类,TextSpeaker,Receiver和SpeakerService。当我启动应用程序,然后点击开始按钮,我得到运行时错误:找不到应用程序的错误android
06-21 13:54:36.088: ERROR/AndroidRuntime(528): Uncaught handler: thread main exiting due to uncaught exception
06-21 13:54:36.119: ERROR/AndroidRuntime(528): java.lang.RuntimeException: Unable to start service [email protected] with Intent { cmp=com.example.TextSpeaker/.SpeakerService }: java.lang.NullPointerException
06-21 13:54:36.119: ERROR/AndroidRuntime(528): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2882)
....
06-21 13:54:36.119: ERROR/AndroidRuntime(528): Caused by: java.lang.NullPointerException
06-21 13:54:36.119: ERROR/AndroidRuntime(528): at com.example.TextSpeaker.SpeakerService.onStart(SpeakerService.java:33)
06-21 13:54:36.119: ERROR/AndroidRuntime(528): at android.app.Service.onStartCommand(Service.java:306)
06-21 13:54:36.119: ERROR/AndroidRuntime(528): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2873)
06-21 13:54:36.119: ERROR/AndroidRuntime(528): ... 10 more
这里是我的3类: TEXTSPEAKER类:
package com.example.TextSpeaker;
import java.util.Locale;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
// the following programme converts the text to speech
public class TextSpeaker extends Activity implements OnInitListener {
/** Called when the activity is first created. */
int MY_DATA_CHECK_CODE = 0;
public TextToSpeech mtts;
public Button button,stop_button;
//public EditText edittext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button);
stop_button=(Button)findViewById(R.id.stop_button);
Intent myintent = new Intent();
myintent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(myintent, MY_DATA_CHECK_CODE);
//edit text=(EditText)findViewById(R.id.edittext);
}
public void buttonClickListener(View src){
switch(src.getId())
{
case(R.id.button):
Toast.makeText(getApplicationContext(), "The service has been started\n Every new message will now be read out", Toast.LENGTH_LONG).show();
startService(new Intent(this,SpeakerService.class));
break;
case(R.id.stop_button):
Toast.makeText(getApplicationContext(), "The service has been stopped\n ", Toast.LENGTH_LONG).show();
stopService(new Intent(this,SpeakerService.class));
break;
}
}
protected void onActivityResult(int requestcode,int resultcode,Intent data)
{
if(requestcode == MY_DATA_CHECK_CODE)
{
if(resultcode==TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
{
// success so create the TTS engine
mtts = new TextToSpeech(this,this);
mtts.setLanguage(Locale.ENGLISH);
}
else
{
//install the Engine
Intent install = new Intent();
install.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(install);
}
}
}
public void onDestroy(Bundle savedInstanceStatBundle)
{
mtts.shutdown();
}
//public void onPause()
//{
// super.onPause();
// // if our app has no focus
// if(mtts!=null)
// mtts.stop();
// }
@Override
public void onInit(int status) {
if(status==TextToSpeech.SUCCESS)
button.setEnabled(true);
}
}
接收机类:
package com.example.TextSpeaker;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage; // supports both gsm and cdma
import android.util.Log;
import android.widget.Toast;
public class Receiver extends BroadcastReceiver{
//TextSpeaker tsp=new TextSpeaker();
public String str="";
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Log.d("Receiver","Message received successfully");
SmsMessage[] msgs = null;
if(bundle!=null)
{
// retrive the sms received
Object[] pdus = (Object[])bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for(int i=0;i
{
msgs[i]=SmsMessage.createFromPdu((byte[]) pdus[i]);
str+="Message From "+msgs[i].getOriginatingAddress()+".";
str+="The message is "+msgs[i].getMessageBody().toString();
}
Toast.makeText(context,str,Toast.LENGTH_SHORT).show();
}
}
}
SERVICESPEAKER类:
package com.example.TextSpeaker;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.widget.Toast;
public class SpeakerService extends Service {
Receiver rv = new Receiver();
TextSpeaker tspker = new TextSpeaker();
//public TextToSpeech mtts;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate(){
//mtts =new TextToSpeech(getBaseContext(), null);
Log.d("SpeakerService","Service created successfully!");
//mtts.speak(rv.str, TextToSpeech.QUEUE_FLUSH,null);
}
@Override
public void onStart(Intent intent,int startid)
{
Log.d("SpeakerService","Service started successfully!");
tspker.mtts.speak(rv.str, TextToSpeech.QUEUE_FLUSH,null);
}
@Override
public void onDestroy(){
if(tspker.mtts!=null)
{
tspker.mtts.stop();
Toast.makeText(getApplicationContext(),"The service has been destroyed!", Toast.LENGTH_SHORT).show();
}
}
}
2010-06-21
pranay
android应用程序在哪找,找不到应用程序的错误android相关推荐
- 对于刚入行的Android程序员来说,找Android培训机构应该注意哪些方面?
人在手足无措的时候,最好的就是静止不动,千万别做盲目冲动的事情. 最起码把该搞清楚的都搞清楚,该了解的都了解.最好能够进行一段时间的自学尝试,零成本试错.除非是非得赶时间.着急速成就业的同学,否则报班 ...
- 漫谈程序员系列:找工作的辟邪剑谱
我原来面试过一个哥们儿,半年内换了七家公司,我表示膜拜. 还有一些哥们儿,七年不换工作.这得是多稳定的工作啊,七年之痒都扛过去了,真心不错. 这都是极端,一般的程序员,可能会一年半载或者三两年换一次工 ...
- Google加强辨识有害程序 运用深度学习找出隐藏关联
Google使用了逻辑回归,并且以深度学习侦测恶意软件特征的隐藏关联,还使用非监督式方法定义行为相似的应用程序群集,有效识别并减轻PHA的威胁. 为了打击在Android中的潜在有害应用程序(Pote ...
- 混淆和7.0以上程序能运行,以下崩溃的原因(第三方类找不到)Zbar程序切到后台扫描出现黑屏
混淆: -optimizationpasses 5 # 指定代码的压缩级别 -dontusemixedcaseclassnames # 是否使用大小写混合 -dontpreverify # 混淆时是否 ...
- pycharm执行python程序报错ImportError: DLL load failed: torchvision找不到指定的程序
ImportError: DLL load failed: 找不到指定的程序 参考 https://blog.csdn.net/shuiyixin/article/details/90370588 C ...
- 成功解决mod = importlib.util.module_from_spec(spec)ImportError: DLL load failed: 找不到指定的程序。
成功解决mod = importlib.util.module_from_spec(spec)ImportError: DLL load failed: 找不到指定的程序. 目录 解决问题 解决思路 ...
- 成功解决Exception unhandled ImportError DLL load failed: 找不到指定的程序。 lib\imp.py, Line: 343
成功解决Exception "unhandled ImportError" DLL load failed: 找不到指定的程序. lib\imp.py, Line: 343 目录 ...
- 使用tensorflow出现 ImportError: DLL load failed: 找不到指定的程序
前言 在使用tensorflow过程中会遇到各种各样的问题,在此记录一下,有助于自己回顾和后来人的学习 问题描述 在anaconda中安装了tensorflow,调用时遇到了这样一个问题: >& ...
- python程序员工作时间_Python程序员是怎么找工作的?怎么最快时间找到自己想要的工作?...
前言 从智联招聘爬取相关信息后,我们关心的是如何对内容进行分析,获取用用的信息. 本次以上篇文章"5分钟掌握智联招聘网站爬取并保存到MongoDB数据库"中爬取的数据为基础,分析关 ...
- Java黑皮书课后题第8章:*8.8(所有最近的点对)修改程序清单8-3,找出所有所有具有最小距离的点对。下面是一个运行示例
*8.8(所有最近的点对)修改程序清单8-3,找出所有所有具有最小距离的点对.下面是一个运行示例 题目 题目描述与运行示例 程序清单8-3 破题 代码 题目 题目描述与运行示例 *8.8(所有最近的点 ...
最新文章
- 写注册机犯法吗_逼着一个受害者去向另一个受害者道歉,不过分吗?
- WinWordControl控件的使用注意
- 华为认证网络互连专家-HCIE-RS模拟试卷
- ApplicationIdle
- hdu2588 GCD
- Chrome插件会干坏事儿的
- java list clear 垃圾回收_list.clear()vs list = new ArrayList Integer(); [重复]
- opencv之图象裁剪
- 班尼机器人维修方法_梅州市ABB机器人控制器维修中心
- c语言默认参数_5.1 C++有默认参数的函数
- 电饼锅的样式图片价格_进口珐琅铸铁锅专场,精致小厨娘们来康康!
- ValueError matplotlib display text must have all code points 128 or use Unicode strings
- 分布式锁在存储系统中的技术实践
- FunDA(9)- Stream Source:reactive data streams
- GIS之旅——大学本科总结
- mysql执行程序_Sql在Mysql的执行
- python 调用大漠
- 三种教鞭工具使用对比
- 申请免费的域名并且通过FTP上传及通过自己的域名访问自己的网站
- Node.js全栈开发笔记与心得