我正在使用 Eclipse 并在调试模式下运行应用程序。我有一个类 - AAStartsHere,派生自 TabActivity。这个派生类启动一个服务(AAservice)。AAService 设置一个 Timer/TimerTask AACallback。在这个回调中,我使用通知设置了一个 Toast。当 AAcallback 调用 Toast 时,传递给 Toast 的参数似乎正常,但屏幕上没有出现或显示任何内容,而是出现了一个新选项卡(标题为 Timer.class)......
这是代码片段
AAStartsHere extends TabActivity {
:
Intent serviceIntent = new Intent (this, AAservice,...);
:
startservice(serviceIntent);
:
}
TimerTask execAACallback = newTimerTask { run() {AAcallback(); } };
AAService extends Service{
onCreate() {
:
AANotifcation = new Notification(....);
:
AATimer.scheduleAtFixedRate(execAACallback, ...)
}
AACallback() {
:
String svcName = Context.NOTIFICATION_SERVICE;
NotificationManager notiMgr = (NotificationManager) getSystemService(svcName);
Context context = getApplicationContext();
String text = "text goes here";
String title = "Title goes here";
Intent AAIntent = new Intent(AAService.this, AAStartsHere.class);
PendingIntent AAPendingIntent = PendingIntent.getActivity(context, 0, AAIntent, 0);
AANotification.setLatestEventInfo(context, title, text, AAPendingIntent);
AANotification.when = java.lang.System.currentTimeMillis();
notiMgr.notify(AA_NOTIFICATION_ID, AANotification);
Toast.makeText(context, title, Toast.LENGTH_LONG).show();
:
}
}
显示的新选项卡(在 Eclipse/调试模式下)具有以下文本 Class File Editor source not found 这个类文件的 JAR 属于容器“Android 2.1”,它不允许修改源附件 //Compiled from timer。 java(版本 1.5:49.0,超级位):
请让我知道你的想法 - 我错过了什么?感谢您的帮助和努力。阿比