Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent sharing actions from creating new instances of the App #25

Closed
gcstr opened this issue Jan 8, 2018 · 5 comments
Closed

Prevent sharing actions from creating new instances of the App #25

gcstr opened this issue Jan 8, 2018 · 5 comments
Labels

Comments

@gcstr
Copy link

gcstr commented Jan 8, 2018

On Android, when any other application uses the system share menu to open and send data to the Application, a new instance is created.

A common way to prevent it would be just forcing singleInstance or singleTask in AndroidManifest.xml:

<activity
...
android:launchMode="singleInstance"
...>
</activity>

But when this is set the following error is thrown:

Attempt to invoke virtual method 'android.content.Intent android.app.Activity.getIntent()' on a null object reference
getSharedText
    ShareMenuModule.java:35
invoke
    Method.java
invoke
    JavaMethodWrapper.java:374
invoke
    JavaModuleWrapper.java:162
run
    NativeRunnable.java
handleCallback
    Handler.java:751
dispatchMessage
    Handler.java:95
dispatchMessage
    MessageQueueThreadHandler.java:31
loop
    Looper.java:154
run
    MessageQueueThreadImpl.java:194
run
    Thread.java:761
@kornfleks
Copy link

kornfleks commented Feb 26, 2018

Add to your app android manifest:
android:documentLaunchMode="never"

For receiving data when app is open you need to add an Event Emitter to the module.

@shekharskamble
Copy link

@caiosba did you manage to work on this issue? any resolution?

@caiosba
Copy link
Collaborator

caiosba commented Oct 8, 2018

I didn't look at it deeply again yet, but when I do, I will take a look at those two commits: pedroordep@156ab35 and Minds@64bb761... you can look at them too :)

@abnerfs
Copy link

abnerfs commented Jan 18, 2019

Add to your app android manifest:
android:documentLaunchMode="never"

For receiving data when app is open you need to add an Event Emitter to the module.

That worked for me, thanks

caiosba added a commit that referenced this issue Jan 18, 2019
@caiosba
Copy link
Collaborator

caiosba commented Jan 18, 2019

Thanks all, I updated the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants