سلام وقت بخیر
من این کد رو نوشتم ولی بهم نوتیفکشن رو نمایش نمیده ،مشخواستم بپرسم مشکل از کجاست؟
کد کلاس َApp:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager notificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel notificationChannel=new NotificationChannel("app","a",NotificationManager.IMPORTANCE_HIGH);
notificationChannel.setDescription("Chanel test");
if(notificationManager!=null)
notificationManager.createNotificationChannel(notificationChannel);
کد در MainActivity:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Notification builder=new NotificationCompat.Builder(this,"a")
.setContentTitle("Notification")
.setContentText("this is a test")
.setSmallIcon(R.drawable.ic_stat_name)
.build();
NotificationManager notificationManager= (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1002,builder);
کد در مانفست:
android:name=".App"
سلام وقت بخیر
کد هایی که فرستادید مشکلی نداشتند فقط طبق کدی که فرستادید تو رفتگی ها رو رعایت کردید؟
در قسمت اول کد که ارسال کردید اونجا که شرط گذاشتید تو رفتگی ها رو رعایت نکردید هر چند بعید میدونم مشکل از اینجا باشه(چک کنین)
if(notificationManager!=null)
notificationManager.createNotificationChannel(notificationChannel);
بهم بگید از امولیتور اندروید استودیو یا سایر استفاده میکنین؟