开发者

GetSystemService DOWNLOAD_SERVICE in non activity

开发者 https://www.devze.com 2023-04-05 05:21 出处:网络
In my simple method in non activity class, I am using code: mgr=(DownloadManager)mContext.getSystemService(DOWNLOAD_SERVICE);

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 strin开发者_开发知识库g. Do you know how to solve that?


Instead you could just write

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

That would compile.

DOWNLOAD_SERVICE is a constant of Context class.


you can use

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号