User:Dcallahan/GeckoView: Difference between revisions

m
Java.
m (Add a ToC back in)
m (Java.)
Line 67: Line 67:
Inside a layout <code>.xml</code> file, add the following:
Inside a layout <code>.xml</code> file, add the following:
<syntaxhighlight lang="XML">
<syntaxhighlight lang="XML">
<org.mozilla.gecko.GeckoView
<org.mozilla.geckoview.GeckoView
     android:id="@+id/geckoview"
     android:id="@+id/geckoview"
     android:layout_width="fill_parent"
     android:layout_width="fill_parent"
Line 74: Line 74:


=== Initialize GeckoView in an Activity ===
=== Initialize GeckoView in an Activity ===
''Note: These snippets are written in [http://kotlinlang.org/ Kotlin]''


'''1. Import the GeckoView classes inside an Activity:'''
'''1. Import the GeckoView classes inside an Activity:'''
<syntaxhighlight lang="Kotlin">
<syntaxhighlight lang="Java">
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoSession
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoView
import org.mozilla.geckoview.GeckoView;
</syntaxhighlight>
</syntaxhighlight>


'''2. In that activity's <code>onCreate</code> function, add the following:'''
'''2. In that activity's <code>onCreate</code> function, add the following:'''
<syntaxhighlight lang="Kotlin">
<syntaxhighlight lang="Java">
val view : GeckoView = findViewById(R.id.geckoview)
GeckoView view = findViewById(R.id.geckoview);
val session = GeckoSession()
GeckoSession session = new GeckoSession();
val runtime = GeckoRuntime.create(this)
GeckoRuntime runtime = GeckoRuntime.create(this);


session.open(runtime)
session.open(runtime);
view.session = session
view.setSession(session);
session.loadUri("https://mozilla.org")
session.loadUri("about:mozilla");
</syntaxhighlight>
</syntaxhighlight>


Confirmed users
170

edits