🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Ramazan HABER / Android Yeni / custom natification

 

1-) Android Yeni -  custom natification

1-) Android Yeni - custom natification
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="150dp"
    android:padding="10dp"
    tools:context="com.example.rambo.servisexample.noticustom">

        <ImageView android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_marginRight="10dp" />
        <TextView android:id="@+id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/image"
            style="Custom Notification Title" />
        <TextView android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/image"
            android:layout_below="@id/title"
            style="Custom Notification Text" />
    </RelativeLayout>

2-) durdursan bile çalışıyor anlamadım
public void noticustom() {
    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.activity_noticustom);
    contentView.setImageViewResource(R.id.image, R.drawable.a);
    contentView.setTextViewText(R.id.title"Custom notification");
    contentView.setTextViewText(R.id.text"This is a custom layout");

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.a)
            .setContent(contentView);

    Notification notification = mBuilder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1, mBuilder.build());// buradaki 1 sayisi uyarıda eğer notificat'nin id=1 ise üzerinde güncelleme yapar. değilse 1 tane daha uyarı verir
    startForeground(1, mBuilder.build());// ezan vakti prodaki gibi hiç kapanmaz
}

 2021 Ocak 18 Pazartesi
 463