Java Question context instanceof VideoShare (= an Activity)

Discussion in 'Libraries developers questions' started by moster67, Apr 17, 2019.

  1. moster67

    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:
    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):

    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?
    Last edited: Apr 17, 2019
  2. moster67

    moster67 Expert Licensed User

    Perhaps doing like this:

    If currentActivityName.EqualsIgnoreCase("VideoShare"Then
    "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....
    Starter.currentActivityName = "VideoShare"
    Last edited: Apr 17, 2019
  3. Erel

    Erel Administrator Staff Member Licensed User

    I don't think that you need this check at all. You should pass a callback object to your class and use it to raise events.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice