对于错误The constructor Intent(new View.OnClickListener(){}, Class<ButtonStudyActivity>) is undefined解决办法:
首先源码:
Notification notification = new Notification(R.drawable.ic_launcher,"" + BMI,System.currentTimeMillis() );
PendingIntent contentIndent = PendingIntent.getActivity(this, 0, new Intent(this,MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
notificationManager.notify(0,notification);
或者是
Intent intent = new Intent(this, ButtonStudyActivity.class);
这里的this,在匿名类中通常是指的是这个匿名类,而不是activity,在indent中需要的是当前activity,所以修改后的代码应该是
new Intent(MainActivity.this,MainActivity.class)
就可以解决