当前位置: 代码迷 >> Android >> 请问下,怎么通过后台service下载,然后点击notifycation图标出现下载界面
  详细解决方案

请问下,怎么通过后台service下载,然后点击notifycation图标出现下载界面

热度:26   发布时间:2016-04-28 00:03:47.0
请教下,如何通过后台service下载,然后点击notifycation图标出现下载界面?

通过service下载我已经实现,但是点击图标,打死也调不出下载的界面?
    private void setupNotification() {
        
       mRemoteView = new RemoteViews(this.getPackageName(), R.layout.y_item_notifymessage);
        mNotification.contentView = mRemoteView;
        
        intent = new Intent(this, Y_Activity_DownManage.class);
        pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
        
      mNotification = new Notification.Builder(ctx)   
        .setAutoCancel(true)   
        .setContentTitle("title")   
        .setContentText("describe")   
        .setContentIntent(pendingIntent)   
        .setContent(mRemoteView)
        .setTicker("开始下载")
        .setSmallIcon(R.drawable.ic_launcher)   
        .setWhen(System.currentTimeMillis())   
        .build();   
        
        mNotificationManager = (NotificationManager) getSystemService( android.content.Context.NOTIFICATION_SERVICE);  
        
        mNotificationManager.notify(10, mNotification);
   
    }
下载类:
public class DownloadService extends Service  implements Runnable {
    @Override
    public void run() {
        // TODO Auto-generated method stub
        
        setupNotification();
        
        //clearNotification();
    }
}
做法类似百度传课的下载!或者慕课的下载!
------解决思路----------------------
你的上下文,试试activity不是你的application
  相关解决方案