Perhaps you are looking for the Layout parameters
]. Use them to determine where your activity or widget is residing on the screen. You would determine where your application is, thus checking whether they are side-by-side or not.
The second question can be answered by the launcher being used. If launcher exposes the details about widgets and apps on the screen then you can get the information.