Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Android push notification is a service which notifies you that has any new data come or not in your smart device.
Android push notification is a service used by developers to send data to Android smartphones.
There are several different methods that can be used to implement Android push messages, the standard way is GCM (Google Cloud Messaging) but the alternatives are everywhere.
So here, We are using simply an alarmManager to make a request to the server after an interval and our custom API to make a response to android smartphones.
This is your primary activity named MainActivity.java, Here we have to set pendingIntent where pendingIntent is the instance of the Intent that starts the Activity when a user touches the push notification.
In above block of code,
alarmIntent – is an object of Intent. PendingIntent – is the instance of the Intent that starts the Activity when a user touches the push notification. AlarmManager – This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. PendingIntent.FLAG_UPDATE_CURRENT – Flag indicating that if the described PendingIntent already exists, then keep it but replace its extra data with what is in this new Intent. For use with getActivity, getBroadcast, and getService.
Here we have set the interval of 1000 * 60 * 60 * 2. Means It will run after every 2 hr.
In step 2, We are making a BroadcastReceiver class named AlarmReceiver.java.
Here, we send a request to the server and server send a response to the client (mobile device) and show to the form of push notification on smartphones.
In above code,
BroadcastReceiver – broadcast receiver who will intercept communication and notify us that something is working in our mobile. It is of 2 types:
Context.sendBroadcast
Context.sendOrderedBroadcast
android:priority
NotificationCompat.Builder – Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts.
NotificationCompat
An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest.xml file.
Paste this xml code inside your <application> tag.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
All communication is done through a ticket system. I appreciate the regular almost daily updates of what is being worked on, and communicating changes or updates is easy through this system. Mobikul's response timeframe is quick.
Josh Arnold
Owner, Shop ATV Escape
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.