本文整理汇总了Java中android.app.DownloadManager.ACTION_DOWNLOAD_COMPLETE属性的典型用法代码示例。如果您正苦于以下问题:Java DownloadManager.ACTION_DOWNLOAD_COMPLETE属性的具体用法?Java DownloadManager.ACTION_DOWNLOAD_COMPLETE怎么用?Java DownloadManager.ACTION_DOWNLOAD_COMPLETE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.DownloadManager
的用法示例。
在下文中一共展示了DownloadManager.ACTION_DOWNLOAD_COMPLETE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadAndInstall
private void downloadAndInstall(String url) {
final DownloadManager dManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
Uri uri = Uri.parse(url);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalPublicDir("zmtmt", "zmtmt_zhibohao_update");
request.setDescription(getString(R.string.new_version_download));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.allowScanningByMediaScanner();
}
request.setMimeType("application/vnd.android.package-archive");
request.setVisibleInDownloadsUi(true);
final long reference = dManager.enqueue(request);
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
upgradeReceiver = new UpgradeBroadcastReceiver(dManager, reference);
registerReceiver(upgradeReceiver, filter);
}
示例2: onReceive
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
case DownloadManager.ACTION_DOWNLOAD_COMPLETE :
btnDownload.setText("下载完成");
btnDownload.setClickable(true);
break;
case NOTIFICATION_CLICKED :
Toast.makeText(MainActivity.this, "通知点击了", Toast.LENGTH_SHORT).show();
if (manager != null)
manager.cancel(1);
break;
case DOWNLOAD_PAUSE :
Toast.makeText(MainActivity.this, "下载暂停", Toast.LENGTH_SHORT).show();
btnDownload.setText("继续下载");
btnDownload.setClickable(true);
break;
}
}
示例3: ReactNativeDownloadManagerModule
public ReactNativeDownloadManagerModule(ReactApplicationContext reactContext) {
super(reactContext);
downloader = new Downloader(reactContext);
appDownloads = new LongSparseArray<>();
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
reactContext.registerReceiver(downloadReceiver, filter);
}
开发者ID:master-atul,项目名称:react-native-simple-download-manager,代码行数:7,代码来源:ReactNativeDownloadManagerModule.java
示例4: InstaDownloader
InstaDownloader(Context inContext){
this.inContext = inContext;
//set filter to only when download is complete and register broadcast receiver
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
inContext.registerReceiver(downloadReceiver, filter);
}
示例5: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
networkUtilities = new NetworkUtilities(this);
setContentView(R.layout.activity_pic_detail);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_detail);
tag_title=(TextView)findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
permissionCheck1 = ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (getIntent().hasExtra(EXTRA_PIC)) {
hit = getIntent().getParcelableExtra(EXTRA_PIC);
} else {
throw new IllegalArgumentException("Detail activity must receive a Hit parcelable");
}
title=hit.getTags();
while(title.contains(",")){
String f=title.substring(0,title.indexOf(","));
tags.add(f);
first=title.indexOf(",");
title=title.substring(++first);
}
tags.add(title);
tag_title.setText(tags.get(0));
wallp = (ImageView) findViewById(R.id.wallpaper_detail);
fav=(TextView)findViewById(R.id.fav);
user_id=(TextView)findViewById(R.id.user_name);
user_image=(ImageView)findViewById(R.id.user_image);
downloads=(TextView)findViewById(R.id.down);
recyclerView=(RecyclerView)findViewById(R.id.tagsRv);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
tagAdapter= new TagAdapter(this);
tagAdapter.setTagList(tags);
recyclerView.setAdapter(tagAdapter);
file = new File(Environment.getExternalStoragePublicDirectory("/"+getResources().getString(R.string.app_name)), hit.getId() + getResources().getString(R.string.jpg));
if(getIntent().hasExtra(origin)){
Picasso.with(this)
.load(file)
.placeholder(R.drawable.plh)
.into(wallp);
isCallerCollection=true;
}
else {
Picasso.with(this)
.load(hit.getWebformatURL())
.placeholder(R.drawable.plh)
.into(wallp);
}
user_id.setText(hit.getUser());
downloads.setText(String.valueOf(hit.getDownloads()));
fav.setText(String.valueOf(hit.getFavorites()));
if(!networkUtilities.isInternetConnectionPresent()){
Picasso.with(this)
.load(R.drawable.memb)
.transform(new CropCircleTransformation())
.into(user_image);
}
else {
if (!hit.getUserImageURL().isEmpty()) {
Picasso.with(this)
.load(hit.getUserImageURL())
.transform(new CropCircleTransformation())
.into(user_image);
} else {
Picasso.with(this)
.load(R.drawable.memb)
.transform(new CropCircleTransformation())
.into(user_image);
}
}
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
registerReceiver(downloadReceiver, filter);
}
示例6: Uri
@Rpc(
description =
"Download a file using HTTP. Return content Uri (file remains on device). "
+ "The Uri should be treated as an opaque handle for further operations."
)
public String networkHttpDownload(String url)
throws IllegalArgumentException, NetworkingSnippetException {
Uri uri = Uri.parse(url);
List<String> pathsegments = uri.getPathSegments();
if (pathsegments.size() < 1) {
throw new IllegalArgumentException(
String.format(Locale.US, "The Uri %s does not have a path.", uri.toString()));
}
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setDestinationInExternalPublicDir(
Environment.DIRECTORY_DOWNLOADS, pathsegments.get(pathsegments.size() - 1));
mIsDownloadComplete = false;
mReqid = 0;
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
BroadcastReceiver receiver = new DownloadReceiver();
mContext.registerReceiver(receiver, filter);
try {
mReqid = mDownloadManager.enqueue(request);
Log.d(
String.format(
Locale.US,
"networkHttpDownload download of %s with id %d",
url,
mReqid));
if (!Utils.waitUntil(() -> mIsDownloadComplete, 30)) {
Log.d(
String.format(
Locale.US, "networkHttpDownload timed out waiting for completion"));
throw new NetworkingSnippetException("networkHttpDownload timed out.");
}
} finally {
mContext.unregisterReceiver(receiver);
}
Uri resp = mDownloadManager.getUriForDownloadedFile(mReqid);
if (resp != null) {
Log.d(String.format(Locale.US, "networkHttpDownload completed to %s", resp.toString()));
mReqid = 0;
return resp.toString();
} else {
Log.d(
String.format(
Locale.US,
"networkHttpDownload Failed to download %s",
uri.toString()));
throw new NetworkingSnippetException("networkHttpDownload didn't get downloaded file.");
}
}
示例7: handleDownloadNotify
private void handleDownloadNotify(long downloadId) {
Intent intent = new Intent(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
intent.putExtra(DownloadManager.EXTRA_DOWNLOAD_ID, downloadId);
new UpdateApkReadyListener().onReceive(context, intent);
}
示例8: goToUpdate
static void goToUpdate(Context context, UpdateFrom updateFrom, URL url) {
IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
context.registerReceiver(downloadReceiver, filter);
descargar(context, url);
}