第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在真實設備中顯示通知的問題

在真實設備中顯示通知的問題

回首憶惘然 2022-06-04 09:35:08
大家好,我為 android 應用程序創(chuàng)建了一個通知,我的代碼在虛擬設備中工作,但在真實設備中不工作,請幫助我。public void onClick(View v){        try {            NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this);            builder.setSmallIcon(R.mipmap.smile);            builder.setShowWhen(true);            builder.setContentText("This is my first notification");            builder.setContentTitle("My Notification");            builder.setAutoCancel(true);            Intent i = new Intent(MainActivity.this, SecondClass.class);            TaskStackBuilder stackBuilder = TaskStackBuilder.create(MainActivity.this);            stackBuilder.addParentStack(SecondClass.class);            stackBuilder.addNextIntent(i);            PendingIntent pi = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);            builder.setContentIntent(pi);            NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);            nm.notify(0, builder.build());            Toast.makeText(getApplicationContext(),"Notification showed!",Toast.LENGTH_LONG).show();        }        catch (Exception e){            Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_LONG).show();        }}
查看完整描述

1 回答

?
呼喚遠方

TA貢獻1856條經驗 獲得超11個贊

原因可能是您的模擬器低于 api 級別 26(oreo)而您的手機,您所說的真實設備大于或等于 api 級別 26,從 oreo 開始,您需要創(chuàng)建通知通道才能顯示通知。欲了解更多信息,請閱讀此處。


查看完整回答
反對 回復 2022-06-04
  • 1 回答
  • 0 關注
  • 67 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號