【发布时间】:2015-01-28 23:04:05
【问题描述】:
如何在 Activity 中启动服务?
我试着打电话:
Notification notification = new Notification(R.drawable.ic_launcher, getText(R.string.app_name),System.currentTimeMillis());
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(this, getText(R.string.app_name),getText(R.string.app_name), pendingIntent);
startForeground(1, notification);
但是,它“无法解析方法'startforeground(int, android.app.Notification)'”
如何调用 startForeground?我试过 getApplicationContext() 无济于事。
【问题讨论】:
标签: java android eclipse oop notifications