我开发了一个应用程序,我需要一个广播接收器来生成有关从 GCM 推送接收消息的通知。
我使用的代码拒绝编译,说明
"Cannot make a static reference to the non-static method acquire() from
the type PowerManager.Wakelock"
IDE(日食)现在建议我应该
remove argument to match "acquire()"
但是,当我这样做时,显示的下一个错误是:
The method acquire(long) in the type PowerManager.WakeLock is not applicable
for the arguements(Context)....
广播接收器的代码是:
private final BroadcastReceiver mHandleMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String newMessage = intent.getExtras().getString(EXTRA_MESSAGE);
WakeLock.acquire(getApplicationContext());
// Showing received message
lblMessage.append(newMessage + "\n");
Toast.makeText(getApplicationContext(), "New Message: " + newMessage, Toast.LENGTH_LONG).show();
// Releasing wake lock
WakeLock.release();
}
我在哪里想念它?