Android system/Samsung/Sony Quick key icon Badgenumber Digital reminder

Source: Internet
Author: User



Android system, Samsung, Sony mobile phone send desktop quick key reminder digital icon, in Android system, well-known does not support Badgenumber, although third-party control Badgeview can implement in-app digital reminders, but for system icons, In particular, the logo of the app is difficult to achieve digital signage, even the way the drawings are constantly modified, but this way is inherently flawed, very poor practicality.



We now come to realize the desktop logo or icon on the top right corner, first look at 2 pictures, the first one from the Internet, the second from the personal practice! (due to experimental conditions Youxia)






Okay, on the code.


public class mainactivity extends activity {      // Must use, Activity start Page       private final static String  Lancheractivityclassname = welcome.class.getname ();       @ Overrideprotected void oncreate (bundle savedinstancestate)  {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.common_listview_layout);} @Overrideprotected  void onresume ()  {super.onresume (); Sendbadgenumber ();} Private void sendbadgenumber ()  {String number =  ";if " (Textutils.isempty ( Number))  {number =  "";}  else {int numint = integer.valueof (number); Number = string.valueof ( Math.max (0, math.min (numint, 99)));} if  (Build.MANUFACTURER.equalsIgnoreCase;  else if  (Build.MANUFACTURER.equalsIgnoreCase ("sAmsung "))  {sendtosony (number);}  else if  (Build.MANUFACTURER.toLowerCase () contains ("Sony"))  {SENDTOSAMSUMG (number);  else {toast.maketext (this,  "Not support",  toast.length_long). Show ();}} Private void sendto(String number)  {try {Class miuiNotificationClass  = class.forname ("Android.app.MiuiNotification");object miuinotification =  Miuinotificationclass.newinstance (); Field field = miuinotification.getclass (). Getdeclaredfield ("Messagecount"); Field.setAccessible ( true); Field.set (Miuinotification, number);//  set the number of messages--this send must be miui 6.} catch  ( exception e)  {    e.printstacktrace (); versions prior to     //miui 6         intent localintent = new intent (" Android.intent.action.APPLICATION_MESSAGE_UPDATE ");        &nbsP;localintent.putextra ("Android.intent.extra.update_application_component_name", Getpackagename ()  +  " /"+ lancheractivityclassname ");         localintent.putextra ( "Android.intent.extra.update_application_message_text", number);         sendbroadcast (localintent);}} Private void sendtosony (String number)  {boolean isShow = true;if  ("0". Equals (number))  {isshow = false;} Intent localintent = new intent (); Localintent.putextra (" Com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE ", isshow);//whether to display Localintent.setaction (" Com.sonyericsson.home.action.UPDATE_BADGE "); Localintent.putextra (" Com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME ",lancheractivityclassname );// Start Page Localintent.putextra ("Com.sonyericsson.home.intent.extra.badge.MESSAGE",  number);// Digital Localintent.putextra ("Com.sonyericsson.home.intent.extra.badge.PACkage_name ", Getpackagename ());//Package name Sendbroadcast (localintent); Toast.maketext (this,  "Sony,"  +  "Issendok",  toast.length_long). Show (); PRIVATE VOID SENDTOSAMSUMG (String number)  {Intent localIntent = new  Intent ("Android.intent.action.BADGE_COUNT_UPDATE"); Localintent.putextra ("Badge_count",  number);// Digital Localintent.putextra ("Badge_count_package_name",  getpackagename ());//Package name Localintent.putextra ("Badge_ Count_class_name ",lancheractivityclassname );  //start Page sendbroadcast (localintent); Toast.maketext (this,  "samsumg,"  +  "Issendok",  toast.length_long). Show ();}}





Note Lancheractivityclassname must be configured as the startup page Android.intent.category.LAUNCHER


 <activity            android:name= " Com.sample.activites.Welcome "            android: Configchanges= "Locale|keyboard|screensize"              android:label= "@string/app_name"              android:screenorientation= "Portrait"  >             <intent-filter>                 <action android:name= "Android.intent.action.MAIN"  />                 <category android:name= " Android.intent.category.LAUNCHER " />             </intent-filter>            <intent-filter>                 <action android: Name= "Android.intent.action.CREATE_SHORTCUT"  />             </intent-filter>        </activity>











Try doing it



Android system/Samsung/Sony Quick key icon Badgenumber Digital reminder


Related Article

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.