赞
踩
这里需要记录一下startForeground使用的注意事项,示例代码来自于Repeater(RPT)源码 com.wudayu.repeater.services.PlayService,代码如下:
- public void useForeground(CharSequence tickerText, String currSong) {
- Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
- PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, 0);
- /* Method 01
- * this method must SET SMALLICON!
- * otherwise it can't do what we want in Android 4.4 KitKat,
- * it can only show the application info page which contains the 'Force Close' button.*/
- NotificationCompat.Builder mNotifyBuilder = new NotificationCompat.Builder(PlayService.this)
- .setSmallIcon(R.drawable.ic_launcher)
- .setTicker(tickerText)
- .setWhen(System.currentTimeMillis())
- .setContentTitle(getString(R.string.app_name))
- .setContentText(currSong)
- .se
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。