![]() ![]() Specifically for getting a reference of WindowManager service, we do something like this. Basically, you define the same AIDL interface on the server side and the client side, and the client is able to call functions of a server service like a normal procedure call. AIDL is short for Android Interface Definition Language. ![]() There’s a way of doing inter-process communication in Android using AIDL. We’ll follow the same approach with our “app”. This means that you can’t call the method getSystemService() in the first place.Ī large part of the Android OS is written in Java and that Java code also accesses the system services without having the application context. However, if you are not running your code inside an Android app, you don’t have an Android context. Normally, you need an instance of WindowManager service to get the device’s dimensions and the code would be something like this- WindowManager window = (WindowManager) getSystemService(Context.WINDOW_SERVICE) ĭisplay display = window.getDefaultDisplay() getting the instance of a system service without having an application context. Hence arose the need for hacking a way to achieve what is mentioned in the title, i.e. ![]() I was supposed to get the display’s width and height. Activity, Service, Broadcast Receiver etc. This means I don’t have access to any Android component i.e. I have been working on a project where I am supposed to execute some Java code, which uses Android APIs, outside the application environment. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |