title: React Native (Intent Redirection fix): What's the equivalent of getCallingActivity() to check for malicious redirection?
body: <p>We were asked to make changes to our react native app when an updated version was submitted to Google Play Store. The issue highlighted was &quot;Intent Redirection&quot; vulnerability. It was legacy code, but nevertheless, better late than never.</p>
  <p>One of the suggested methods in the Google help <a href="https://support.google.com/faqs/answer/9267555?hl=en" rel="noreferrer">guide</a> was this:</p>
  <blockquote>
  <p>Option 2: Ensure that the extracted Intent is from a trustworthy source.</p>
  <p>You can verify that the originating Activity can be trusted using methods like &gt;getCallingActivity. For example:</p>
  </blockquote>
  <pre><code> // check if the originating Activity is from trusted package
   if (getCallingActivity().getPackageName().equals(“known”)) {
     Intent intent = getIntent();
     // extract the nested Intent
     Intent forward = (Intent) intent.getParcelableExtra(“key”);
     // redirect the nested Intent
     startActivity(forward);
   }
  </code></pre>
  <p>On changing code as per this guidance, the build showed an error that <code>getCallingActivity</code> was not a known symbol. The code already uses <code>getCurrentActivity</code> and <code>getApplicationContext</code>.</p>
  <p>What would be the best way for us to rectify in our React Native app, this vulnerability in our native Java code?</p>
  <p><strong>Will deeply appreciate your quick support here. Thanks!</strong></p>