Android 活动未从状态栏通知开始

Android 活动未从状态栏通知开始,android,notifications,android-pendingintent,Android,Notifications,Android Pendingintent,我发现了很多关于这个问题的堆栈溢出帖子,但是它们都使用了现在不推荐使用的通知方法,而不是使用Notification.Builder类 我正在成功创建状态栏通知,但单击后什么也没有发生。LogCat中会显示一条警告: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@412d6df0 以下是我用来生成通知的代码: public class

我发现了很多关于这个问题的堆栈溢出帖子,但是它们都使用了现在不推荐使用的通知方法,而不是使用Notification.Builder类

我正在成功创建状态栏通知,但单击后什么也没有发生。LogCat中会显示一条警告:

Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@412d6df0
以下是我用来生成通知的代码:

public class LunchNotificationBuilder {

private Notification notification;
public LunchNotificationBuilder(Lunch lunch, Context context) {
    Builder builder = new Builder(context);
    Calendar reminderTime = (Calendar)lunch.getReminderTime().clone();
    builder.setWhen(reminderTime.getTimeInMillis());
    builder.setTicker("Reminder for " + lunch.getTitle());
    builder.setContentTitle("LunchBunch Notification");
    builder.setContentText("Upcoming lunch at " + lunch.getTitle());
    builder.setSmallIcon(R.drawable.ic_launcher);
    Intent intent = new Intent(context, InviteDetails.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT));
    this.notification = builder.getNotification();
}

public Notification getNotification() {
    return this.notification;
}

}
午餐类只是我创建的一个数据结构,不用担心

传入的上下文是Application.getApplicationContext

我正在按照文档中的建议设置Intent.FLAG\u ACTIVITY\u NEW\u TASK标志,并且pendingent具有pendingent.FLAG\u ONE\u SHOT标志


另一个注意事项:当我在代码的其他地方显式调用startActivity时,我尝试启动的活动InviteDetails工作正常。这个悬而未决的生意有些不起作用

结果是我不知道如何使用Android。我是在单击顶部的状态栏,而不是在单击之前向下拖动以查看完整的通知。我的代码正在运行。啊

结果是我不知道如何使用Android。我是在单击顶部的状态栏,而不是在单击之前向下拖动以查看完整的通知。我的代码正在运行。啊

尝试在getActivity中传递不同的请求代码。但可能不是您想要的。请尝试在getActivity中传递不同的请求代码。但可能不是你想要的。