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); }
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 } }
评论
发表评论