跳至主要内容

android notification

private void simpleNotify(String ticker , String title, String content, String subText){
    NotificationCompat.Builder builder = new NotificationCompat.Builder(MyService.this);
    builder.setTicker(ticker);
    builder.setContentTitle(title);
    builder.setContentText(content);
    builder.setSubText(subText);
    builder.setContentInfo("2");
    builder.setNumber(2);
    builder.setAutoCancel(true);
    builder.setSmallIcon(R.mipmap.ic_launcher);
    builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
    Intent intent = new Intent(MyService.this,MainActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(MyService.this,1,intent,0);
    builder.setContentIntent(pIntent);
    builder.setDefaults(NotificationCompat.DEFAULT_SOUND);
    Notification notification = builder.build();
    NotificationManager manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    manager.notify(1,notification);
}

评论

此博客中的热门博文

android hide actionbar

public class MainActivity extends Activity { ActionBar actionBar; //声明ActionBar @Override protected void onCreate( Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView( R .layout.activity_main); actionBar = getSupportActionBar(); //得 到ActionBar actionBar.hide(); //隐藏ActionBar } }

go url encoding

func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits. func  QueryUnescape func QueryUnescape (s string ) ( string , error ) QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.