标签:serve nts size EDA contains 链接 res seda segment
通过监听ContentObserver监听下载路径content://downloads
context.getContentResolver()
.registerContentObserver(DOWNLOAD_URI, true, new ContentObserver() {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
parseData(uri);
}
});
public void parseData(Uri uri) {
List<String> segments = uri.getPathSegments();
if (segments != null && segments.size() > 1) {
String segment = (String) segments.get(1);
synchronized (this.pathSegments) {
if (this.pathSegments.contains(segment)) {
return;
}
this.pathSegments.add(segment);
}
this.obtainAppInfo(segment);
}
}
应用信息获取:
private void obtainAppInfo(String segment){
...
cursor = this.queryDownloadPkg(downloadUri);
if (cursor == null || cursor.getColumnCount() < 15) {
return;
}
cursor.moveToNext();
String marketName = cursor.getString(9); // 应用市场包名
String appLink = cursor.getString(15); // 下载应用的包名链接
String appName = cursor.getString(20); //获取应用名称
...
}
标签:serve nts size EDA contains 链接 res seda segment
原文地址:https://www.cnblogs.com/diffx/p/9541346.html