saji-fun! 0 ارسال شده در ۲۹ مرداد ۱۳۹۳ گزارش اشتراک گذاری ارسال شده در ۲۹ مرداد ۱۳۹۳ سلام! این کد برای نوتیفیکیشن هست! ولی کاربر با زدن دکمه ی clear اونو میتونه پای کنه! حالا من میخوام کاری کنم که تا زمانی که اپلیکیشنم باز هست یا در پشت صفحه باز هست این نوتیفیکیشن پاک نشه! چیکار باید بکنم؟؟؟ اینم کد نوتیفیکیشن! [shcode=java] package com.botskool.StatusBarNotification; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; public class StatusBarNotificationActivity extends Activity { private static final int NOTIFICATION_ID = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); int icon = R.drawable.icon; CharSequence tickerText = "This is a sample notification"; long when = System.currentTimeMillis(); Context context = getApplicationContext(); CharSequence contentTitle = "Sample notification"; CharSequence contentText = "This notification has been generated as a result of button click."; Intent notificationIntent = new Intent(this, StatusBarNotificationActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); final Notification notification = new Notification(icon, tickerText, when); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); String ns = Context.NOTIFICATION_SERVICE; final NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); Button statusbarnotify = (Button) findViewById(R.id.statusbarbutton); statusbarnotify.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mNotificationManager.notify(NOTIFICATION_ID, notification); } }); } } [/shcode] نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
Majid Ebrahimi 19 ارسال شده در ۲۹ مرداد ۱۳۹۳ گزارش اشتراک گذاری ارسال شده در ۲۹ مرداد ۱۳۹۳ startForeground(66, notification); نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
saji-fun! 0 ارسال شده در ۲۹ مرداد ۱۳۹۳ مالک گزارش اشتراک گذاری ارسال شده در ۲۹ مرداد ۱۳۹۳ ببخشید میشه بگید کجا باید این کد رو بزارم؟؟؟ یکم توضیحی ، چیزی.... نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
Majid Ebrahimi 19 ارسال شده در ۲۹ مرداد ۱۳۹۳ گزارش اشتراک گذاری ارسال شده در ۲۹ مرداد ۱۳۹۳ بعد از اینکه نوتیفیکیشنتان را در سرویس ساختید نقل قول لینک ارسال به اشتراک گذاری در سایت های دیگر
پست های پیشنهاد شده
به گفتگو بپیوندید
هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .