Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Bugfix for a possible issue on Android 11 MIUI devices
Browse files Browse the repository at this point in the history
  • Loading branch information
yasirkula committed Oct 28, 2021
1 parent 43b225d commit ebdde2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ else if( "huawei".equalsIgnoreCase( android.os.Build.MANUFACTURER ) )
shouldUseCustomShareDialog = true; // At least some Huawei devices don't support callback for unknown reasons
}

if( !shouldUseCustomShareDialog && IsXiaomiOrMIUI() && IsUnityInLandscapeMode( (Activity) context ) )
shouldUseCustomShareDialog = true; // At least some Xiaomi devices can't display share dialog properly when in landscape mode (Issue #56)
// 1) MIUI devices have issues with Intent.createChooser on at least Android 11 (https://stackoverflow.com/questions/67785661/taking-and-picking-photos-on-poco-x3-with-android-11-does-not-work)
// 2) At least some Xiaomi devices can't display share dialog properly when in landscape mode (Issue #56)
if( !shouldUseCustomShareDialog && IsXiaomiOrMIUI() && ( Build.VERSION.SDK_INT == 30 || IsUnityInLandscapeMode( (Activity) context ) ) )
shouldUseCustomShareDialog = true;

if( shouldUseCustomShareDialog )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.yasirkula.unity;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.os.Build;
import android.util.Log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import android.app.Activity;
import android.app.Fragment;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

/**
* Created by yasirkula on 11.07.2020.
Expand Down Expand Up @@ -36,10 +38,18 @@ public void onCreate( Bundle savedInstanceState )
final Intent shareIntent = NativeShare.CreateIntentFromBundle( getActivity(), getArguments() );
final String title = getArguments().getString( NativeShareFragment.TITLE_ID );

if( Build.VERSION.SDK_INT < 22 )
startActivityForResult( Intent.createChooser( shareIntent, title ), SHARE_RESULT_CODE );
else
startActivityForResult( Intent.createChooser( shareIntent, title, NativeShareBroadcastListener.Initialize( getActivity() ) ), SHARE_RESULT_CODE );
try
{
if( Build.VERSION.SDK_INT < 22 )
startActivityForResult( Intent.createChooser( shareIntent, title ), SHARE_RESULT_CODE );
else
startActivityForResult( Intent.createChooser( shareIntent, title, NativeShareBroadcastListener.Initialize( getActivity() ) ), SHARE_RESULT_CODE );
}
catch( ActivityNotFoundException e )
{
Toast.makeText( getActivity(), "No apps can perform this action.", Toast.LENGTH_LONG ).show();
onActivityResult( SHARE_RESULT_CODE, Activity.RESULT_CANCELED, null );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.yasirkula.nativeshare",
"displayName": "Native Share",
"version": "1.4.2",
"version": "1.4.3",
"documentationUrl": "https://github.com/yasirkula/UnityNativeShare",
"changelogUrl": "https://github.com/yasirkula/UnityNativeShare/releases",
"licensesUrl": "https://github.com/yasirkula/UnityNativeShare/blob/master/LICENSE.txt",
Expand Down

0 comments on commit ebdde2d

Please sign in to comment.