0
我想在用户拉下通知并点击该通知时调用该活动...我该怎么做?通知激活
这里是我的代码:
public class SetReminder extends AppCompatActivity {
int notifyID = 1088;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
TextView helpsubtitle = (TextView)findViewById(R.id.subtitle_help);
Typeface typeface = Typeface.createFromAsset(getAssets(), "beyond_the_mountains.ttf");
helpsubtitle.setTypeface(typeface);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.diamond)
.setContentTitle("Crystallise")
.setContentText("making your thoughts crystal clear");
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(notifyID, mBuilder.build());
}
}
雷说无法解析符号背景+ asc42 –
你需要传递的上下文。 由于您已经在一个活动中,并且您正在从活动本身创建通知,因此应该用'SetReminder.this'替换'context' – adhirajsinghchauhan