Unity Android Local Notification

Source: Internet
Author: User

Record the local notifications for the Android version of Unity Games in the form of plugins. This is the main reference. Make a slight change. Related files are shared with code on GitHub.
Implementation steps 1.Inside the Windows system, double-click Cdz_build.bat. A alarmreceiver.jar is generated in the current directory.
2.Copy the Alarmreceiver.jar into the assets\plugins\android\libs\ directory of the Unity project.
3.Generate a local notification:
Androidjavaobject nativeobj = new Androidjavaobject ("Com.macaronics.notification.AlarmReceiver"); Nativeobj.callstatic ("Startalarm", New Object[5]{title,title, MSG, Secondsfromnow, triggertimeint});
the meaning of the parameter:Title: Caption of the notification msg: content of the notification Secondsfromnow: the time distance from the notification is now the number of seconds Triggertimeint: a random number
Cancel all local notifications:
Androidjavaobject Playeractivitycontext = null;using (var actclass = new Androidjavaclass (" Com.unity3d.player.UnityPlayer ")) {Playeractivitycontext = Actclass.getstatic<androidjavaobject> (" CurrentActivity ");} using (Androidjavaclass Javaclass = new Androidjavaclass ("Com.macaronics.notification.AlarmReceiver")) { Javaclass.callstatic ("Clearnotification", Playeractivitycontext);}

Reference: Unity 3D + Local Notification for AndroidAndroid Alarmmanager Set up multiple timed events only last valid problem solvedPendingintentnotification.builderhow exactly to use Notification.builder

Document Information

    • Original URL: http://blog.csdn.net/cdztop/article/details/39699675
    • Last modified: October 01, 2014 14:47

Unity Android Local Notification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.