iOS Question [SOLVED] How to make ActivityViewController go away

JackKirk

Well-Known Member
Licensed User
Longtime User
Hi,

An annoying little problem...

I launch ActivityViewController with code like:
B4X:
'Start share, see:
'https://www.b4x.com/android/forum/threads/get-details-of-the-apps-my-app-shares-files-with.128687/
UI_activityviewcontroller.Initialize("Event_UI_activityviewcontroller", Array(wrk_bmp))
                               
'Wait for share to complete
UI_activityviewcontroller.Show(Showlist_page, Null)
Wait For Event_UI_activityviewcontroller_Complete(wrk_success As Boolean, wrk_activitytype As String)
which works fine - in normal circumstances.

In some circumstances the bitmap is too large to be shared to the nominated sharing app and as a result UI_activityviewcontroller completes with wrk_success = False

BUT

the ActivityViewController view doesn't go away - it sits waiting for the user to tap an alternate share app or to tap its exit (X) button.

When it fails I want to be able to dialog the user with the option of reducing the bitmap and retrying - how can I programmatically make the ActivityViewController view go "poof".

Thanks for any help...
 

JackKirk

Well-Known Member
Licensed User
Longtime User
If I tap the area above the ActivityViewController pop-up it disappears - is there a way to programmatically synthesise that?

Also a question which may form the basis of a workaround: on my iPhone the ActivityViewController pop-up only occupies the bottom half of the screen - is this a constant across the iPhone universe?
 
Last edited:
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel, we just dynamically crossed paths - you probably didn't see the second part of post #3 which might provide a workaround.

How will you know that the third party app failed to handle image?
When a third party app fails to handle an image being shared the _Complete event Success parameter is false and the activityType parameter contains the package name of the failing third party app - but this is also the state when the user cancels the share after nominating the third party app. This is why I was interested in getting the error message generated when a failure actually occurs (see https://www.b4x.com/android/forum/threads/capturing-activityviewcontroller-error-messages.129571/)

I've been working on a workaround which I would be happy with if I could be assured that the ActivityViewController pop-up only occupies the bottom half of the screen across the iPhone universe.
 
Last edited:
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
B4X:
B4X:
Dim no As NativeObject = UI_activityviewcontroller
no.RunMethod("dismissModalViewControllerAnimated:", Array(True))
Erel, not wanting to be picky but according to:
https://developer.apple.com/documen...ller/1621369-dismissmodalviewcontrolleranimat
dismissModalViewControllerAnimated is deprecated in favour of:
https://developer.apple.com/documen...troller/1621505-dismissviewcontrolleranimated

Any chance you could update your suggestion?

Thanks in anticipation...
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Any chance you could update your suggestion?
No need to bother, I fudged it:
B4X:
Dim no As NativeObject = UI_activityviewcontroller
no.RunMethod("dismissViewControllerAnimated:completion:", Array(False, Null))
 
Upvote 0
Top