In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how android realizes system information push". Xiaobian shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "how android realizes system information push" can help you solve the problem.
1. Determine whether to start the App instead of refreshing the interface to execute the method
if (! window.name) { window.name = 'test'; InfoPush(data.data.length)}
2. The system information pushes the main code, sets the content to be displayed, icons and other information, and tests it on Huawei mobile phones. Other mobile phones are not clear about the effect.
//system information push function InfoPush(len) { if (plus.os.name == 'Android') { //Current version number var SystemVersion = plus.os.version; var Context = plus.android.importClass("android.content.Context"); var main = plus.android.runtimeMainActivity(); var NotificationManager = plus.android.importClass("android.app.NotificationManager"); var nm = main.getSystemService(Context.NOTIFICATION_SERVICE) // Notification build requires android api16 or above to use (4.1.2 or above) var Notification = null; if (compareVersion('4.1.1', SystemVersion) == true) { Notification = plus.android.importClass("android.app.Notification"); } else { Notification = plus.android.importClass("android.support.v4.app.NotificationCompat"); } if (Notification) { var NotifyID = 1; var mNotification = new Notification.Builder(main); var Intent = plus.android.importClass("android.content.Intent"); var PendingIntent = plus.android.importClass("android.app.PendingIntent"); var intent = new Intent(main, main.getClass()); var pendingIntent = PendingIntent.getActivity(main, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); var r = plus.android.importClass("android.R"); // mNotification.setOngoing(true); //whether fixed mNotification.setContentTitle("ZZApp") mNotification.setContentText("you have" + len + "new information") mNotification.setSmallIcon(r.drawable.ic_notification_overlay) mNotification.setTicker("ZZApp") mNotification.setContentIntent(pendingIntent); //click to jump mNotification.setAutoCancel(true)//click to delete var mNb = mNotification.build() nm.notify(NotifyID, mNb); } }}
3. Comparison According to the version size of the mobile phone, importing related class objects through the plus.android.importClass(name) method does not have much effect.
/** * Compare two versions in size * Compare version sizes, return true if new version nowVersion is greater than old version OldResourceVersion, otherwise return false */ function compareVersion(OldVersion, nowVersion) { if (! OldVersion || ! nowVersion || OldVersion == '' || nowVersion == '') { return false; } //The second argument is the maximum length of the array var OldVersionA = OldVersion.split(". ", 4); var nowVersionA = nowVersion.split(". ", 4); for (var i = 0; i
< OldVersionA.length && i < nowVersionA.length; i++) { var strOld = OldVersionA[i]; var numOld = parseInt(strOld); var strNow = nowVersionA[i]; var numNow = parseInt(strNow); //小版本到高版本 if (numNow >numOld //||strNow.length>strOld.length ) { return true; } else if (numNow
< numOld) { return false; } } //如果是版本 如 1.6 - 1.6.1 if (nowVersionA.length >OldVersionA.length && 0 == nowVersion.indexOf(OldVersion)) { return true; } };
Effect drawing:
About "android how to achieve system information push" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the industry information channel. Xiaobian will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.