jitsi / jitsi-meet-sdk-samples

Jitsi Meet mobile SDK examples (Android, iOS and React Native)
Apache License 2.0
277 stars 240 forks source link

App Not redirecting to ongoing meeting when minimized #81

Closed tusharsonawanes closed 3 years ago

tusharsonawanes commented 3 years ago

Hello, I have cloned the latest Android SDK and I have run both the java and the kotlin version in my android studio. I have the following issue in both the versions.

When I create a meeting, and I minimize it, the pip mode works great, but when I click the app icon, it takes me back to the start page ( where I am asked the meeting name ) when my current meeting is going on.

This doesn't happen in the official Jitsi Meet app. In the official version, if I am in a meeting and I minimize jitsi meet, the pip mode works great and when I click jitsi meet app icon, it takes me to the current ongoing meeting.

@imrushi and I have tried to resolve this but no luck. I have attached a screenshot below for your reference.!

Screenshot_20201024-150442.jpg

imrushi commented 3 years ago

@saghul cn you help us with this issue ? Where do we make changes for resolving this ?

saghul commented 3 years ago

I know why you are seeing this, but I don't know how to address it. In the sample app there is an Activity (MainActivity) which launches JitsiMeetActivity, and when you tap the app icon, MainActivity is what you see. The Jitsi Meet app is somewhat special, because its MainActivity is in fact an instance of JitsiMeetActivity, there is just one activity.

imrushi commented 3 years ago

@saghul thank you for the quick help. I want to ask, how can we, at our end resolve this issue? If you could give us some examples or give us a hint which will resolve this issue?

Do we need to modify the SDK? Or do we need to change the code to redirect it to JitsiMeetActivity only? If it's not too much, can I share my code with you? I am just stuck on this one issue Thank you once again for the help.

saghul commented 3 years ago

You don't need to modify the SDK for this. I don't know exactly how, but this needs to be solved in your app, by doing something with the intent sent to MainActivity.

tusharsonawanes commented 3 years ago

Sorted out. Can close the issue :) thanks for the help @saghul

saghul commented 3 years ago

Mind sharing how you solved it? It may help others!

tusharsonawanes commented 3 years ago

@imrushi share the code. @saghul can we submit a PR ?

tusharsonawanes commented 3 years ago

@saghul we were actually gonna ask you that ! If we could share. lol

imrushi commented 3 years ago

Solution

  1. To check if the meeting is going on or not create a boolean using SharedPreferences on the join meeting button when the user clicks the button bool is set to true.
public static final String met= "met";

public void onButtonClick(View v) {
        EditText editText = findViewById(R.id.conferenceName);
        String text = editText.getText().toString();

        if (text.length() > 0) {
           JitsiMeetConferenceOptions options
                = new JitsiMeetConferenceOptions.Builder()
                    .setRoom(text)
                    .build();
            JitsiMeetActivity.launch(this, options);
            SharedPreferences sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);

            SharedPreferences.Editor editor = sharedpreferences.edit();
            editor.putBoolean(met,true);
            editor.commit();
        }
    }
  1. when the user goes into the picture in picture mode form page (where take all inputs) goes is on paused state when we clock on the app icon it calls resume state. So in onResume() in MainActivity.java check if the meeting is going on or not if it's going redirect him to the meeting. MainActivity.java

    @Override
    protected void onResume() {
        super.onResume();
        SharedPreferences sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);
    
        //get boolean value from shared preferences which we are store when joining meeting button is clicked
    
        boolean check = sharedpreferences.getBoolean(met,false);
        if (check){
            //if meeting is going on redirect to meeting
            startActivity(new Intent(this, JitsiMeetActivity.class)
                    .addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
        }
    }
  2. when the user leaves the meeting shared preferences should set to false so for that, you should add JitsiMeetViewListener in which onConferenceTerminated() you should add this

           @Override
            public void onConferenceTerminated(Map<String, Object> map) {
                Log.d(TAG, "onConferenceTerminated: set sharedpref false");
                SharedPreferences sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);

                SharedPreferences.Editor editor = sharedpreferences.edit();
                editor.putBoolean(bol,false);
                editor.commit();
            }
  1. in onDestroy() add this
 @Override
    protected void onDestroy() {
        super.onDestroy();
        SharedPreferences sharedpreferences = getSharedPreferences("MyPrefs", Context.MODE_PRIVATE);

        SharedPreferences.Editor editor = sharedpreferences.edit();
        editor.putBoolean(bol,false);
        editor.commit();
    }

I hope this will help and solve everyone's problem.

saghul commented 3 years ago

@imrushi share the code. @saghul can we submit a PR ?

Yeah, a PR would make sense here.

saghul commented 3 years ago

I think you could store a flag in the Application, instead of using shared preferences.

imrushi commented 3 years ago

@saghul Yes, we could store a flag in the Application.

eraArya2601 commented 3 years ago

@saghul I am getting same error in android by using react-native.I am adding flag but app not redirect to meeting.Please suggest how should I resolve this issue.