Android Multiple permission easy way

private static final int PERMISSION_REQUEST_CODE = 1;
            // task after permission granted.
        } else {
private boolean checkPermission(){
        int result = ContextCompat.checkSelfPermission(this,
        if (result == PackageManager.PERMISSION_GRANTED){

            return true;

        } else {

            return false;
 private void requestPermission(){

        ActivityCompat.requestPermissions(this,new String[]{

    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        switch (requestCode) {
                if (grantResults.length > 0 && grantResults[0] + grantResults[1] == PackageManager.PERMISSION_GRANTED) {

                } else {

                    Snackbar.make(findViewById(,"Permission Denied, Please allow to proceed !", Snackbar.LENGTH_LONG).show();


Android Download PDF file and Save to Downloads folder and Open it with a PDF Viewer

Download PDF file and Store it to Downloads folder

DownloadManager downloadmanager;

    downloadmanager = (DownloadManager) getApplication().getSystemService(Context.DOWNLOAD_SERVICE);
    String url = hardcode + bb ;
    Uri uri = Uri.parse(url);
    DownloadManager.Request request = new DownloadManager.Request(uri)
            .setTitle(bb )
    Log.i("Download1", String.valueOf(request));

Open PDF file from Downloads folder and show it on a PDF viewer

File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() + File.separator +
            "YOUR FILE NAME");
    Uri path = Uri.fromFile(file);
    Log.i("Fragment2", String.valueOf(path));
    Intent pdfOpenintent = new Intent(Intent.ACTION_VIEW);
    pdfOpenintent.setDataAndType(path, "application/pdf");
    try {
    } catch (ActivityNotFoundException e) {


Denial of service (DoS) attack

A denial-of-service attack overwhelms a system’s resources so that it cannot respond to service requests. A DDoS attack is also an attack on system’s resources, but it is launched from a large number of other host machines that are infected by malicious software controlled by the attacker.

Unlike attacks that are designed to enable the attacker to gain or increase access, denial-of-service doesn’t provide direct benefits for attackers. For some of them, it’s enough to have the satisfaction of service denial. However, if the attacked resource belongs to a business competitor, then the benefit to the attacker may be real enough. Another purpose of a DoS attack can be to take a system offline so that a different kind of attack can be launched. One common example is session hijacking, which I’ll describe later.

There are different types of DoS and DDoS attacks; the most common are TCP SYN flood attack, teardrop attack, smurf attack, ping-of-death attack and botnets.

What is Language Integrated Language(LINQ)? Describe the advantage of LINQ.

What is LINQ?

LINQ (Language Integrated Query) is uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. It is integrated in C# or VB, thereby eliminating the mismatch between programming languages and databases, as well as providing a single querying interface for different types of data sources.

For example, SQL is a Structured Query Language used to save and retrieve data from a database. In the same way, LINQ is a structured query syntax built in C# and VB.NET to retrieve data from different types of data sources such as collections, ADO.Net DataSet, XML Docs, web service and MS SQL Server and other databases.

Advantages of LINQ

  • Familiar language: Developers don’t have to learn a new query language for each type of data source or data format.
  • Less coding: It reduces the amount of code to be written as compared with a more traditional approach.
  • Readable code: LINQ makes the code more readable so other developers can easily understand and maintain it.
  • Standardized way of querying multiple data sources: The same LINQ syntax can be used to query multiple data sources.
  • Compile time safety of queries: It provides type checking of objects at compile time.
  • IntelliSense Support: LINQ provides IntelliSense for generic collections.
  • Shaping data: You can retrieve data in different shapes.