如何在下载接收器中访问本地文件名?

时间:2016-08-09 10:20:17

标签: java android broadcastreceiver

我试图获取下载文件的文件路径,我提供的接收器可以工作,但我怎样才能获得文件名/路径?

内部onReceive

String action = intent.getAction();
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {

    DownloadManager.Query q = new DownloadManager.Query();
    Cursor c = this.query(q); // how to get access to this since there is no instance of DownloadManager

    try {
        String filePath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME));
        Log.i("DOWNLOAD LISTENER", filePath);

    } catch(Exception e) {

    } finally {
        c.close();
    }

}
  

无法解析方法查询(...)

1 个答案:

答案 0 :(得分:3)

您可以通过common_cols = ['Customer_Name','Customer_No'] df = (pd.read_excel(filename1) .join(pd.read_excel(filename2, usecols=common_cols), on=common_cols)) 的{​​{1}}方法查看DownloadManager个实例。

这样的事情应该有效:

getSystemService()