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