×
Namespaces

Variants
Actions
(Difference between revisions)

Creating a Nokia X App for Your Website using Android WebView

From Nokia Developer Wiki
Jump to: navigation, search
BuildNokia (Talk | contribs)
(BuildNokia - edited for clarity)
BuildNokia (Talk | contribs)
(BuildNokia -)
Line 5: Line 5:
 
[[File:Nokiaxz.jpg]]
 
[[File:Nokiaxz.jpg]]
  
I have divided this tutorial into 3 parts:
+
I have divided this tutorial into 3 parts
  - Android Layout File
+
  * Android Layout File
  - Activity
+
  * Activity
  - Android Manifest
+
  * Android Manifest
  
 
== 1. Android Layout File ==  
 
== 1. Android Layout File ==  

Revision as of 01:29, 17 April 2014

Contents

Introduction

So, you're an owner of a website, and you want to build an app like the Facebook mobile app for the Nokia X platform, WebView will help you. Yes, Android’s WebView allows you to make a Nokia X App so users can access your website easily and directly.

Nokiaxz.jpg

I have divided this tutorial into 3 parts

* Android Layout File
* Activity
* Android Manifest

1. Android Layout File

File : res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

2. Activity

Activity will display the WebView with a predefined URL. You need to specify the URL of your website here.

File : MainActivity.java

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.view.Window;
import android.webkit.WebView;
 
public class MainActivity extends Activity {
 
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
 
//Add the URL of your Website here
webView.loadUrl("http://mashable.com");
}
}

3. Android Manifest

WebView required INTERNET permission. Add the following code into AndroidManifest.xml.

<uses-permission android:name="android.permission.INTERNET" />


File : AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.proj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
 
<uses-permission android:name="android.permission.INTERNET" />
 
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.proj.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>


Example application

You can find the source code for an example in Github the Nokia X WebView project on Github.

This example was based on the Proj Webview app, published by Rathee.ashish.1712, in the Nokia Store.

158 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×