Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat code is running when I call getSystemService() from my activity?
    primarykey
    data
    text
    <p>I'm trying to trace AOSP code from the <a href="http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.1_r1/android/content/Context.java?av=f" rel="nofollow">grepcode site</a>.</p> <p>When I call <code>getSystemService(Context.WIFI_P2P_SERVICE)</code>, it gets to the following code:</p> <pre><code> @Override public Object getSystemService(String name) { if (getBaseContext() == null) { throw new IllegalStateException( "System services not available to Activities before onCreate()"); } if (WINDOW_SERVICE.equals(name)) { return mWindowManager; } else if (SEARCH_SERVICE.equals(name)) { ensureSearchManager(); return mSearchManager; } return super.getSystemService(name); } </code></pre> <p>And since <code>WIFI_P2P_SERVICE</code> declared as <code>public static final String WIFI_P2P_SERVICE = "wifip2p";</code>, if will not fall in one of the conditions and will go to the <code>super.getSystemService(name);</code></p> <pre><code>Activity extends ContextThemeWrapper, the code there is: @Override public Object getSystemService(String name) { if (LAYOUT_INFLATER_SERVICE.equals(name)) { if (mInflater == null) { mInflater = LayoutInflater.from(mBase).cloneInContext(this); } return mInflater; } return mBase.getSystemService(name); } </code></pre> <p>Here also, the required service name will not match, <code>mBase</code> is an instance of <code>Context</code> so the code in Context is:</p> <pre><code>public abstract Object getSystemService(String name); </code></pre> <p>which means that classes which extends from it must handle that functionality. <strong>Well, Where my request is being treated?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload