android - Java: Need some way to shorten this code -


I have a piece of code that I would like to shorten ...

  PackageManager P = context.getPackageManager (); Last list & lt; PackageInfo & gt; Appinstall = p.getInstalledPackages (PackageManager.GET_PERMISSIONS); PackageManager pro = context.getPackageManager (); Last list & lt; PackageInfo & gt; Apllprovides = pro.getInstalledPackages (PackageManager.GET_PROVIDERS);  

To add new flag permissions, I am seriously worried about doing this repeatedly, and I have to do this twice, there is a small method in which I have everything I can put the flag on the same definition ... ???

I was given it like this, can I do it ... ??? (Of course this gives an error, but something similar ..)

  PackageManager p = context.getPackageManager (); Last list & lt; PackageInfo & gt; Appinstall = p.getInstalledPackages (PackageManager.GET_PERMISSIONS) .addFlag (PackageManager.GET_PROVIDERS);  

If it has the same syntax as C # and the flags are set correctly , You can do this:

  PackageManager p = context.getPackageManager (); Last list & lt; PackageInfo & gt; Appinstall = p.getInstalledPackages (PackageManager.GET_PERMISSIONS | PackageManager.GET_PROVIDERS)  

Comments