android - 使用PendingIntent的编译错误

因此,我正在处理大量代码,这些代码将使我可以从顶部的状态栏运行应用程序,这是进入其中的好方法,并且几乎完成了。我只需要对为什么我的“PendingIntent.getActivity(this,that,next,thing);”拥有第二意见。它没有编译。
这是代码

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;

public class NotifyMe extends Activity {
NotificationManager nm;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    Intent MainActivity = new Intent(this, MainActivity.class);
    PendingIntent pi = new PendingIntent.getActivity(this, 0, intent, 0);
    String body = "Simple message";
    String title = "Hello World";
    Notification n = new Notification(R.drawable.note, body, System.currentTimeMillis());
    n.setLatestEventInfo(this, title, body, pi);

}
}

因此,我可能做错了所有事情,对此问题的任何提示将不胜感激。

最佳答案

 PendingIntent pi = new PendingIntent.getActivity(this, 0, intent, 0);

不需要新的。

更重要的是,您需要集中精力进行Eclipse环境设置,以便至少可以查看错误消息。它们应该在称为问题的区域中发生,并且当您在StackOverflow上报告错误时,可以包含错误消息是什么。如果您对您的环境有疑问,请告诉我们。

https://stackoverflow.com/questions/11530830/

相关文章:

flash - 无法解析 to a component imple

c# - 简单的代理asp.net错误

android - 修复了C代码中的错字,仍然无法构建

xcode - 项目清理后,Cocos2d/box2d项目将无法编译

winapi - InterlockedPushListSList丢失。它在哪里?

ruby-on-rails - SCSS编译错误

.net - ObservableCollection-无法实现,因为它没有匹配的返回类型

python - 错误 : invalid mode ('r' ) - Cannot conduct

ruby-on-rails - 使用Mysql在共享服务器中部署Rails应用程序时出错

windows - libqxt编译-mingw32-make异常