17 Simple Notification Program






Notification Example program:
===========================
package com.example.aslam.simplenotification1;

import android.app.NotificationManager;
import android.support.v4.app.NotificationCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    NotificationCompat.Builder notification;
    private static final int uniqueID=45612;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        notification=new NotificationCompat.Builder(this);
        notification.setAutoCancel(true);

    }
    public void notificationClick(View view) {
     notification.setSmallIcon(R.drawable.ic_launcher_background);
    notification.setTicker("you have received a message");
    notification.setWhen(System.currentTimeMillis());
    notification.setContentTitle("Whats app ");
    notification.setContentText("Venu sir message received");
        NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
        nm.notify(uniqueID,notification.build());
    }
}



Comments

  1. Nice Blog and this article however I find that you are making some seo mistakes like
    1. Linking images I mean your image structure is < a > < img src=#" > < / a>
    You have to Remove manually tag < a > < / a >
    2. Use compressed images you can use website Imagediamond For image compressing
    3. Not Linking Like you can link these apps play store URL it will help user and also google to understand your page intent

    ReplyDelete

Post a Comment

Popular posts from this blog

20 Simple Content Provider Example

14 Popup Menu

19 SQLIte SImple Database Example