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

app crash on share #1185

Open
BootsBack opened this issue Aug 18, 2022 · 5 comments
Open

app crash on share #1185

BootsBack opened this issue Aug 18, 2022 · 5 comments

Comments

@BootsBack
Copy link

BootsBack commented Aug 18, 2022

Android 12 API Level 31
my app crash on click
<\button onclick="window.plugins.socialsharing.share(null, 'Android filename', 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null)">base64 image only</button>

@pedropamn
Copy link

Maybe because it's a base64 image... If you use Android Studio, can you paste what logcat says?

@BootsBack
Copy link
Author

line 274:
final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);

change with this:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_IMMUTABLE); }
else {
pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT); }

      Full code check attach file

SocialSharing.java.txt

@merbin2012
Copy link

line 274: final PendingIntent pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);

change with this:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) { pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_IMMUTABLE); } else { pendingIntent = PendingIntent.getBroadcast(cordova.getActivity().getApplicationContext(), 0, receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT); }

      Full code check attach file

SocialSharing.java.txt

You are awesome. Thank you very much it is working in Android 12 and the lower versions.

@herman-nieuwoudt-specno

It is in the SocialSharing.java.txt, but you also have to change the pendingIntent.getIntentSender() to finalPendingIntent.getIntentSender()). This is in line 377 or 385

chooseIntent = Intent.createChooser(sendIntent, chooserTitle, finalPendingIntent.getIntentSender());

@danieldanielecki
Copy link

For those with an error if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {^ symbol: variable S Cannot resolve symbol 'S' :301 increase the compileSdkVersion to 31, source: https://stackoverflow.com/questions/65044161/build-failed-error-cannot-find-symbol-if-build-version-sdk-int-build-versio (For me 29 was causing issues).

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

5 participants