-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the onNewIntent listener to React Native Android
Reviewed By: foghina Differential Revision: D3475896 fbshipit-source-id: d8e5d7734974132307a85d21e4c1602327a479fa
- Loading branch information
Showing
5 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
ReactAndroid/src/main/java/com/facebook/react/bridge/BaseActivityEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2004-present Facebook. All Rights Reserved. | ||
|
||
package com.facebook.react.bridge; | ||
|
||
import android.content.Intent; | ||
|
||
/** | ||
* An empty implementation of {@link ActivityEventListener} | ||
*/ | ||
public class BaseActivityEventListener implements ActivityEventListener { | ||
|
||
@Override | ||
public void onActivityResult(int requestCode, int resultCode, Intent data) { } | ||
|
||
@Override | ||
public void onNewIntent(Intent intent) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2fc0f40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grabbou heads-up: this is a breaking change. I changed the
ActivityEventListener
interface, so now it allows modules to listen toActivity.onNewIntent
. There are many functionalities in Android that require that, like listening to NFC data. If you implement that interface, you will now need to add an implementation ofpublic void onNewIntent(Intent intent)
I've added theBaseActivityEventListener
abstract class as a convenience, but you will obviously only be able to use it if you don't extend some other class.Let me know if you need more info!
2fc0f40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should be moved to
IntentAndroid
module now that there is aonNewIntent
event -react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerImpl.java
Line 473 in 2fc0f40
2fc0f40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@satya164 Not sure I understand your comment
2fc0f40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following code belongs to the
IntentAndroid
module,It was added here since there was no way for a module to know when
onNewIntent
was called.2fc0f40
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this help with InputMediaService applications? I have a keyboard that won't work on Android(iOS) is fine because getCurrentActivity returns null from my InputMediaService context. Perhaps there is a another interface that can be added to handle that?:
#7762