Android 状态栏上未显示通知
我正在尝试在状态栏上发送通知,单击按钮后应立即发送此通知。 我正在使用下面的代码,还参考了一些示例,但在运行时,按钮单击事件的状态栏上没有显示任何内容 请让我知道我错过了什么 代码1:发送上行消息:Android 状态栏上未显示通知,android,notifications,android-notifications,android-pendingintent,Android,Notifications,Android Notifications,Android Pendingintent,我正在尝试在状态栏上发送通知,单击按钮后应立即发送此通知。 我正在使用下面的代码,还参考了一些示例,但在运行时,按钮单击事件的状态栏上没有显示任何内容 请让我知道我错过了什么 代码1:发送上行消息: mBtn_send = (Button) findViewById(R.id.btn_send_notification); mBtn_send.setOnClickListener(new View.OnClickListener() { @Override
mBtn_send = (Button) findViewById(R.id.btn_send_notification);
mBtn_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "TOAST", Toast.LENGTH_LONG).show();
try {
send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
});
}
public void send() throws PendingIntent.CanceledException {
Intent intAct = new Intent(this, ActPending.class);
PendingIntent pending = PendingIntent.getActivity(this, 1, intAct, PendingIntent.FLAG_UPDATE_CURRENT);
//pending.send();
String title = getString(R.string.app_name);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setStyle(new NotificationCompat.BigTextStyle().bigText("BIG TEXT")).setContentText("CONTENTS").setContentTitle(title);
builder.setContentIntent(pending).setAutoCancel(true);
((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(1, builder.build());
}
你有日志吗?如果在
send()
方法中添加一个断点,它就成功了?@Kevinrob我将断点放在Intent inframe=new Intent(这是ActPending.class);它被调用了,没有任何内容是空的..我应该调用.send
,如果你“一步一步地”去,它能工作吗?任何logcat?检查设备中是否为此禁用了通知app@BatCat已在应用程序上禁用通知。然后重新出血,但没有任何变化