Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetSystemService DOWNLOAD_SERVICE in non activity

In my simple method in non activity class, I am using code:

mgr=(DownloadManager)mContext.getSystemService(DOWNLOAD_SERVICE); 

in non activity class, my constructor looks like:

public Download23(Context context){
    this.mContext=context;
}

But compilator won't accept DOWNLOAD_SERVICE string. Do you know how to solve that?

like image 734
Waypoint Avatar asked Sep 14 '11 05:09

Waypoint


2 Answers

Instead you could just write

(DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE); 

That would compile.

DOWNLOAD_SERVICE is a constant of Context class.

like image 135
Vincent Vettukal Avatar answered Nov 02 '22 04:11

Vincent Vettukal


you can use

(DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE); 
like image 29
Mohammed Azharuddin Shaikh Avatar answered Nov 02 '22 02:11

Mohammed Azharuddin Shaikh