How to obtain RTTI from an interface reference in Delphi?
<p>Is it possible to implement a function like this?</p>

<pre><code>function GetRttiFromInterface(AIntf: IInterface; out RttiType: TRttiType): Boolean;
</code></pre>

<p>I have the following code (on Firemonkey Android):</p>

<pre><code>// Get the FWeb field of AWebBrowser, then get FJWebBrowser field of FWeb.
function GetNativeBrowserIntf(AWebBrowser: TWebBrowser): IInterface;
var
  LCtx: TRttiContext;
  LWeb: TObject;
begin
  LWeb := (LCtx.GetType(TWebBrowser).GetField('FWeb').GetValue(AWebBrowser).AsInterface as TObject);
  result := LCtx.GetType(LWeb.ClassInfo).GetField('FJWebBrowser').GetValue(LWeb).AsInterface;
end;

{ TODO : How to get rtti from an interface reference??? }
function GetRttiFromInterface(AIntf: IInterface; out RttiType: TRttiType): Boolean;
begin
  //RttiType := TRttiContext.Create.FindType('Androidapi.JNI.Embarcadero.JWebBrowser');
  //I want to get rtti from AIntf without knowing the qulified type name
  result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  NativeBrowser: IInterface;
  LIntfType: TRttiType;
  LScale: Single;
begin
  // obtain native browser Interface (JWebBrowser)
  NativeBrowser := GetNativeBrowserIntf(WebBrowser1);
  // Get Rtti from this interface
  if GetRttiFromInterface(NativeBrowser, LIntfType) then
  begin
   // Invoke the getScale method of Native Browser
    LScale := LIntfType.GetMethod('getScale').Invoke(TValue.From&lt;IInterface&gt;(NativeBrowser), []).AsType &lt; Single &gt; ;
    ShowMessage('Current scale is:' + LScale.ToString);
  end;
end;    
</code></pre>

<p>How to get RTTI from an interface reference without its qualified type name?</p>

<p>For example, I have an <code>IInterface</code> instance named <code>AInterface</code>. Assume its actual type is <code>Androidapi.JNI.Embarcadero.JWebBrowser</code>,
I can get its RTTI by:</p>

<pre><code>TRttiContext.Create.FindType('Androidapi.JNI.Embarcadero.JWebBrowser');
</code></pre>

<p>What I want to do is obtain its RTTI without knowing its qualified type name.</p>

<p>For instances of <code>TObject</code>, I can use:</p>

<pre><code>RttiType := TRttiContext.Create.GetType(AObject.ClassType);
</code></pre>

<p>But for instances of interfaces:</p>

<pre><code>RttiType := TRttiContext.Create.GetType(AInterface);   
</code></pre>

<p>doesn't work.</p>