Java Question context instanceof VideoShare (= an Activity)

moster67

Expert
Licensed User
Just wondering if anyone could give me a helping hand...

I am converting below code into B4A in my Starter service.
I have a problem with the following condition check:
B4X:
if (context instanceof VideoShare) { //VideoShare is an activity
    '// ((VideoShare) context).onVideoChannelStreamStopped(channelInstance);
    'here I will use CallSubDelayed() and run this part in the VideoShare activity
}
I have been trying using "GetType", "me", "is" in various combinations but no luck so far.

Below is the full method as a reference (it's an event):

B4X:
 @Override
    public void onVideoChannelStreamStopped(VideoChannel channelInstance){
        Log.d(TAG,"onVideoChannelStreamStopped channelInstance : "+channelInstance);

        VideoChannel videoChannel = repository.getSharedVideoChanel();
        if (videoChannel != null) {
            if(videoChannel.equals(channelInstance)) {
                if (context instanceof VideoShare) {
                    ((VideoShare) context).onVideoChannelStreamStopped(channelInstance);
                }
            }
        }
    }
Any idea how I can do the condition check in B4A?
Thanks.
 
Last edited:

moster67

Expert
Licensed User
Perhaps doing like this:

B4X:
If currentActivityName.EqualsIgnoreCase("VideoShare") Then
        CallSubDelayed2(VideoShare,"OnVideoChannelStreamStopped", ChannelInstance)
    End If
where currentActivityName is a String variable I write in each Activity present in the project with the name of the Activity....
B4X:
Starter.currentActivityName = "VideoShare"
 
Last edited:
Top