使用的PendingIntent编译错误 [英] Compilation error using PendingIntent

查看:212
本文介绍了使用的PendingIntent编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的工作code一大块,让我运行一个应用了顶部状态栏的我是一个很好的方式进入,并基本完成。我只需要在第二个观点为什么我的PendingIntent.getActivity(这个,那个,接下来,东西);它不是编译。
这里的code

 进口android.app.Activity;
进口android.app.Notification;
进口android.app.NotificationManager;
进口android.app.PendingIntent;
进口android.content.Intent;
进口android.os.Bundle;公共类NotifyMe延伸活动{
NotificationManager纳米;@覆盖
保护无效的onCreate(捆绑savedInstanceState){
    // TODO自动生成方法存根
    super.onCreate(savedInstanceState);
    纳米=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    意图MainActivity =新意图(这一点,MainActivity.class);
    PI的PendingIntent =新PendingIntent.getActivity(这一点,0,意向,0);
    绳体=简单的消息;
    字符串title =Hello World的;
    通知N =新的通知(R.drawable.note,身体,System.currentTimeMillis的());
    n.setLatestEventInfo(这一点,标题,正文,PI);}
}

所以,我可能会做这一切错了,在这个问题上的任何提示,将大大AP preciated。


解决方案

 的PendingIntent PI =新PendingIntent.getActivity(这一点,0,意向,0);

不需要新的。

更重要的是,你需要把重点放在让您的Eclipse环境的设置,这样你至少可以查看错误消息。他们应该发生在被称为问题的区域,当你在计算器上报告错误,则可以将错误信息是什么。让我们知道,如果你有关于环境的问题。

So I'm working on a chunk of code that will allow me to run an app out of the Status bar at the top I'm a good way into it and almost finished. I just need a second opinion on why my "PendingIntent.getActivity(this,that,next,thing);" Its not compiling. Here's the code

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);

}
}

So I might be doing this all wrong, any tips in this matter will be greatly appreciated.

解决方案

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

Dont need new.

More importantly, you need to focus on getting your eclipse environment setup so that you can at least view the error messages. They should occur in an area called Problems, and when you report an error on StackOverflow you can include what the error message is. Let us know if you have questions about your environment.

这篇关于使用的PendingIntent编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆