nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this,EU.class);
pd = PendingIntent.getActivity(EU.this, 0, intent, 0);
bt01 = (Button)findViewById(R.id.button1);
OnClickListener onclick = new OnClickListener() {
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
baseNF = new Notification();
baseNF.tickerText = "You clicked BaseNF!";
baseNF.setLatestEventInfo(EU.this, "Title01", "Content01", pd);
nm.notify(1, baseNF);
}
};
bt01.setOnClickListener(onclick);
不知道是哪里有问题呢?请高人指教。谢谢。代码是写在 super.onCreate(savedInstanceState);下的
- 自己回答问题。。。。。。
权限不足够,补上权限即可,但是目前很多教程都没说这个。
<permission android:name="android.permission.STATUS_BAR_SERVICE" android:protectionLevel="signature" />