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

Switching out of Android app closes file - why? #270

Open
SteveW117 opened this issue Sep 17, 2019 · 11 comments
Open

Switching out of Android app closes file - why? #270

SteveW117 opened this issue Sep 17, 2019 · 11 comments

Comments

@SteveW117
Copy link

Currently testing version 2.0.19 with Cordova 6.5.0.

I can open PDFs and other files in Android and iOS OK. However, in Android if I switch away from the app (e.g. to the Home screen or recent apps) and switch back to my app, the file has closed. There seem to be no errors logged, but it means the user must then open the file again (which works).

I have also noticed in Android that if I open a PDF it seems to open within the app - but in the recent apps screen I can see 2 tabs, one for my app and one for the PDF. If I click my app the above behaviour occurs - if I click the PDF it simply disappears and dumps me back to the Home screen!

Are these behaviours expected? I have looked through all the issues and can't see anyone else reporting them... In iOS everything works as expected, the file opens within the app and I can switch out and back into it with no problems.

Any help or advice appreciated!

@pawelzwronek
Copy link
Contributor

pawelzwronek commented Oct 6, 2019

Try replace line in file FileOpener2.java function _open
from
cordova.getActivity().startActivity(intent);
to
cordova.getActivity().getApplicationContext().startActivity(intent);
It helped me to run uninstall and open older version of apk to do self downgrade.

Or add Intent.FLAG_ACTIVITY_NEW_TASK in intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NO_HISTORY);

@SteveW117
Copy link
Author

Thanks - did you experience the Android behaviour I described? It does not seem to have been widely reported. I wondered if it was because my Cordova and plugin versions were out-of-date... I am not working on the project right now but will log your suggestions for next time I am on it, Thanks again!

@anypoint-aus
Copy link

I know this is old thread, but I also have same issue with latest plugin and cannot find a solution. I tried the changes above did not help. Some investigation I did seems to suggest maybe services are required to keep the activity running after it goes to the background?

@pawelzwronek
Copy link
Contributor

For me crucial was this commit 3eb2bc7
Make sure flag Intent.FLAG_ACTIVITY_NO_HISTORY is removed

@anypoint-aus
Copy link

Thanks @pawelzwronek seems to be working nicely now!

@Sampath-Lokuge
Copy link

@pawelzwronek This is not working again with 3.0.3. It has your fix too. Any clue?

Error

message: "Activity not found: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://com.reno.fileOpener2.provider/files/csvExport.csv typ=text/csv flg=0x3 }"
status: 9

@pawelzwronek
Copy link
Contributor

Is it working with any older version?

@Sampath-Lokuge
Copy link

@pawelzwronek No. I started from this 2.2.1. After that this 3.0.1 That version showed this error Fixed: Failed to find configured root that contains "/data/data/{app_name_redacted}/files/" So then I used this 3.0.3.

@pawelzwronek
Copy link
Contributor

So why did you write "not working AGAIN", like it worked for you in the past? This is some new bug on you side or the plugin, right?

@Sampath-Lokuge
Copy link

@pawelzwronek I have given that feedback due to this comment #270 (comment) i.e. I hope it worked for him and you on Feb. But now it is not working. I have used 2.2.1 for a very long time period and it worked. But due to the new Android 10 support where I have upgraded my app to API level 29. After that this functionality is not working anymore.

@pawelzwronek
Copy link
Contributor

It looks like new Android 10 is the issue. Can you describe the use case, when you get the error?

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

No branches or pull requests

4 participants