in my project my image are getting downloaded perfectly now I only wanted to know how should I display that downloaded images in "view downloads" activity which is present in navigation drawer...please anybody how can I display
download function in my activity:
downloadimage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DownloadManager.Request request = new DownloadManager.Request(
Uri.parse(imgUrl));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.
Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "/my_file.JPEG");
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(), "Downloading File",
Toast.LENGTH_LONG).show();
}
});
view downloads activity(I haven't done here anything)edit please:
public class NextActivity extends AppCompatActivity {
ImageView myImage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_next);
myImage = (ImageView) findViewById(R.id.down);
//getActionBar().setDisplayHomeAsUpEnabled(true);
// getActionBar().setHomeButtonEnabled(true);
//Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//setSupportActionBar(toolbar);
// this.getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
File imgFile = new File( Environment.DIRECTORY_DOWNLOADS, "/my_file.JPEG");
if(!(imgFile==null)){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getPath());
myImage.setImageBitmap(myBitmap);
Log.d("ashwiniiii","ashwiniii");
}
else {
myImage.setImageResource(R.drawable.ic_launcher_background);
}
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
assert navigationView != null;
//navigationView.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
if (getSupportActionBar() != null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//getSupportActionBar().setHomeButtonEnabled(true);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish(); // close this activity and return to preview activity (if there is any)
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
}}