> you're trying to create a GeckoRuntime

This should read: you're trying to  re-create a GeckoRuntime, in essence
you can only create the runtime in a given process once. When rotating
Android re-uses the process of your app and re-runs the initialization
code, causing the runtime to be created a second time.

On Tue, May 5, 2020 at 10:07 AM Agi Sferro <asfe...@mozilla.com> wrote:

> Hi Bob, that's pretty cool!
>
> GeckoView should support Android 4.1 (API level 16) for all versions,
> however we don't test on that version, so you might encounter bugs.
>
> The crash on rotation is probably due to the fact that you're trying to
> create a GeckoRuntime in the same process, you can deal with this using a
> static variable for the runtime, see [1].
>
> GeckoViewExample (code linked above) supports tabs, you can get an idea
> how to implement that from reading the code. In essence you would create a
> `GeckoSession` for each tab and then call `geckoView.setSession(session)`,
> see also [2].
>
> [1]:
> https://searchfox.org/mozilla-central/rev/7908ce29657cfd623993046bd8e38664e1c0b28e/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java#377
> [2]:
> https://searchfox.org/mozilla-central/rev/7908ce29657cfd623993046bd8e38664e1c0b28e/mobile/android/geckoview_example/src/main/java/org/mozilla/geckoview_example/GeckoViewActivity.java#1030-1041
>
> On Tue, May 5, 2020 at 7:06 AM Bob Achgill <bobachg...@hotmail.com> wrote:
>
>> Hello GeckoView developers/users,
>>
>> I am new to Java and GeckoView and have a few questions.  My use case is
>> ...
>> There are presently 1.5 billion children out of school due to C19.
>> I am making a quick Geckoview app that they can use to continue to learn
>> from home on their family smart phone.  Think Jelly Bean on up.
>> I already 1.8 GB mother tongue html video curriculums that we have been
>> using firefox for them to locally browse the curriculum.
>> Here is where GeckoView comes in... it will be much easier for families
>> to use an app integrated with the html viewing built in.
>>
>> Here are my hurdles to getting GV going in my app
>> 1) On both 70.0.20190712095934 and 77.0.20200421094220 my S7 GV crashes
>> when turning the phone between portrait and landscape.  That seems like I
>> must be doing something really wrong with setting up the GV session?  (see
>> my activity below)
>>
>> 2) I have some clients on 4.1.  Is there a way of knowing which builds of
>> GV support which min SDKs?  Is there a way to tweak GV to get down to
>> support 4.1?
>>
>> 3) What is the code I add to support tabs?  Siblings in the same home
>> then can use their own tab view after brother does his homework with no
>> complaints.
>>
>>
>> Thanks so much!
>> Bob Achgill
>>
>> PS  You can see from my code that I commented out lines in trying to set
>> up the settings.  There is not much in the way of examples to follow that I
>> just didn't get AS giving me complaints on so i had to // them out.  So
>> please feel free to add to my humble attempts!  Your inputs will help kids
>> around the world start getting productive this week. :)
>> ~~~
>>
>> package org.hishandsreader.mygeckoview;
>>
>> import androidx.appcompat.app.AppCompatActivity;
>>
>> import android.os.Bundle;
>> import android.view.View;
>> import android.view.WindowManager;
>>
>> // GeckoView
>> https://mozilla.github.io/geckoview/consumer/docs/geckoview-quick-start.html
>> import org.mozilla.geckoview.GeckoRuntime;
>> import org.mozilla.geckoview.GeckoRuntimeSettings;
>> import org.mozilla.geckoview.GeckoSession;
>> import org.mozilla.geckoview.GeckoSessionSettings;
>> import org.mozilla.geckoview.GeckoView;
>>
>>
>>
>>
>>
>> public class MainActivity extends AppCompatActivity {
>>
>>     private GeckoView geckoview;
>>     private GeckoSession geckoSession;
>>     private GeckoRuntime geckoRuntime;
>>     // test
>>     private boolean mCanGoBack;
>>
>>     @Override
>>     protected void onCreate(Bundle savedInstanceState) {
>>         super.onCreate(savedInstanceState);
>>         setContentView(R.layout.activity_main);
>>
>> // GeckoView
>> https://mozilla.github.io/geckoview/consumer/docs/geckoview-quick-start.html
>>         GeckoView view = findViewById(R.id.geckoview);
>>
>>         geckoSession = new GeckoSession();
>>
>> //geckoSession.getSettings().setBoolean(GeckoSessionSetttings.USE_MULTIPROCESS,
>> true);
>>
>> //geckoSession.getSettings().setBoolean(GeckoSessionSetttings.USE_DESKTOP_MODE,
>> false);
>>
>>         GeckoRuntimeSettings.Builder builder = new
>> GeckoRuntimeSettings.Builder()
>>                 .javaScriptEnabled(true)
>>                 //// .nativeCrashReportingEnabled(true)
>>                 .consoleOutput(true);
>>
>>         geckoRuntime = GeckoRuntime.create(MainActivity.this,
>> builder.build());
>>
>>         ////geckoview.setSession(geckoSession geckoRuntime);
>>
>>         geckoSession.open(geckoRuntime);
>>         view.setSession(geckoSession);
>>
>>
>>         //geckoSession.loadUri( "https://exploitrme.wordpress.com/";);
>>
>>         //
>> https://github.com/mozilla-mobile/android-components/issues/5968
>>
>> geckoSession.loadUri("resource://android/assets/www/HHR-Learn2Read.html");
>>         //TODO  Pixel api 19 never online
>>         //TODO  Pixl 29 shows app but no html
>>         //TODO  Bobs S7 works!! Backbutton works!
>>         //TODO get help try to understand this to sper backbutton?
>> https://qiita.com/YusukeIwaki/items/3c25f7b73650c87180ba
>>
>>         // In Japanese
>> https://qiita.com/YusukeIwaki/items/3c25f7b73650c87180ba
>>         // @Override
>>         //public void onBackPressed()
>>         //{
>>         // session.goBack();
>>         //}
>>
>>
>>     }
>>
>>     @Override
>>     public void onBackPressed() {
>>         //if (geckoSession.canGoBack()) {
>>         geckoSession.goBack();
>>         //} else {
>>         //    super.onBackPressed();
>>         //}
>>     }
>>
>>
>>
>> // Does not appear to be doing anything.
>>     public void onFullScreen(GeckoSession geckoSession, boolean
>> fullScreen) {
>>         if (fullScreen) {
>>
>> getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
>>
>> getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
>>                     | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
>>                     | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
>>                     | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
>>                     | View.SYSTEM_UI_FLAG_FULLSCREEN
>>                     | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
>>         } else {
>>
>> getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
>>
>> getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
>> | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
>>             geckoSession.exitFullScreen();
>>         }
>>     }
>> }
>>
>>
>> _______________________________________________
>> mobile-firefox-dev mailing list
>> mobile-firefox-dev@mozilla.org
>> https://mail.mozilla.org/listinfo/mobile-firefox-dev
>>
>
_______________________________________________
mobile-firefox-dev mailing list
mobile-firefox-dev@mozilla.org
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to