本文整理匯總了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);
}