انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل در نوتیفیکشن

مشکل در نوتیفیکشن

#1
Bug 
سلام من یک نوتیفیکشن ساختم که میخوام کاربر بتونه تو تنظیمات اون رو خاموش یا روشن کنه
من تنظیمات رو درست کردم که وقتی swich خاموشه نشون نده وقتی تغییر داد نشون بده که درست کار میکنه اما وقتی دوباره می خوام خاموش بشه خطا میده
swich پیش فرض روی خاموش هست واسه همین درست کا میکنه کد هام رو اینجا میزارم ممنون میشم کسی بتونه کمکی کنه
هرچند مبهم توضیح دادم

اینها صفحه اصلی برنامه که تو oncreat هستند
کد پی‌اچ‌پی:
SharedPreferences notification getSharedPreferences("notiffsett",
                
MODE_PRIVATE);
        
boolean norifbollen notification.getBoolean("notiffk"true);
 
        if (
norifbollen) {
 
            
notification1 = new Notification(R.drawable.ic_launcher,
                    
"برنامه من"System.currentTimeMillis());
 
            
mNotificationManager = (NotificationManagergetSystemService(NOTIFICATION_SERVICE);
 
            
RemoteViews contentView = new RemoteViews(getPackageName(),
                    
R.layout.custom);
            
contentView
                    
.setImageViewResource(R.id.imageR.drawable.ic_launcher);
            
contentView.setTextViewText(R.id.title"نکات مورد نظر");
            
contentView.setTextViewText(R.id.text,
                    
"|در اینجا نکات قرار می گیرد|در اینجا نکات قرار می گیرد|");
            
notification1.contentView contentView;
 
            
Intent notificationIntent = new Intent(thisMain_page.class);
            
PendingIntent contentIntent PendingIntent.getActivity(this0,
                    
notificationIntent0);
            
notification1.contentIntent contentIntent;
 
            
notification1.flags |= Notification.FLAG_ONGOING_EVENT;
            
notification1.flags |= Notification.FLAG_HIGH_PRIORITY;
            
mNotificationManager.notify(1notification1);
        } else {
            
//اشکال برنامه اینجا باید باشه
            // notification1.flags |= Notification.FLAG_AUTO_CANCEL;
        

اینها هم تو اکتیویتی تنظیمات
کد پی‌اچ‌پی:
//in 3 satr to oncreat hast
notification getSharedPreferences("notiffsett"MODE_PRIVATE);
norifbollen notification.getBoolean("notiffk"true);
swnoti.setChecked(norifbollen);
 
//این 3 سطر هم وقتی باتن ذخیره کلیک میشه
SharedPreferences.Editor notiedit notification.edit();
notiedit.putBoolean("notiffk"swnoti.isChecked());
notiedit.commit(); 
بازم ممنون
 
پاسخ


پیام‌های این موضوع
مشکل در نوتیفیکشن - توسط saeed.f436 - ۱۳۹۴/۰۵/۱۴, ۱۰:۵۷ ب.ظ
RE: مشکل در نوتیفیکشن - توسط saeed.f436 - ۱۳۹۴/۰۵/۱۴, ۱۱:۰۰ ب.ظ
RE: مشکل در نوتیفیکشن - توسط aliasghar - ۱۳۹۴/۰۵/۱۵, ۰۲:۲۲ ب.ظ

پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان