【发布时间】:2017-08-29 12:36:59
【问题描述】:
我正在使用 android studio,我正在处理一部分代码,这部分代码来自我将其转换为 android studio 的 eclipse 项目。 问题出在:
notification.setLatestEventInfo(this, text,
getText(R.string.notification_subtitle), contentIntent);
setLatestEventInfo是红色的,无法启动应用程序,如果解决这个问题怎么办?
/**
* Show a notification while this service is running.
*/
private void showNotification() {
CharSequence text = getText(R.string.app_name);
Notification notification = new Notification(R.drawable.ic_notification, null,
System.currentTimeMillis());
notification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
Intent pedometerIntent = new Intent();
pedometerIntent.setComponent(new ComponentName(this, Pedometer.class));
pedometerIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
pedometerIntent, 0);
notification.setLatestEventInfo(this, text,
getText(R.string.notification_subtitle), contentIntent);
mNM.notify(R.string.app_name, notification);
}
这是错误:
Error:(375, 21) error: cannot find symbol method setLatestEventInfo(StepService,CharSequence,CharSequence,PendingIntent)
还有这个:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
【问题讨论】:
标签: java android eclipse android-studio