Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Creating a Nokia X App for Your Website using Android WebView

From Wiki
Jump to: navigation, search
rathee.ashish.1712 (Talk | contribs)
(Rathee.ashish.1712 - - Example application)
BuildNokia (Talk | contribs)
(BuildNokia - edited for clarity)
Line 1: Line 1:
 
[[Category:Draft]][[Category:Nokia X]][[Category:Nokia X 1.0]]
 
[[Category:Draft]][[Category:Nokia X]][[Category:Nokia X 1.0]]
 
== Introduction ==
 
== Introduction ==
So, you're an owner of website, and you want to build an app like Facebook mobile app for Nokia X platform but does not want to spend more then WebView will help you.  
+
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.
Yes, Android’s WebView allows you to make a Nokia X App using which users can access your website easily and directly.
+
  
 
[[File:Nokiaxz.jpg]]
 
[[File:Nokiaxz.jpg]]
  
I have divided this tutorial in 3 parts:-
+
I have divided this tutorial into 3 parts:
 +
- Android Layout File
 +
- Activity
 +
- Android Manifest
  
 
== 1. Android Layout File ==  
 
== 1. Android Layout File ==  
  
'''File : res/layout/activiy_main.xml'''
+
'''File : res/layout/activity_main.xml'''
 
<br/>
 
<br/>
 
<code>
 
<code>
Line 22: Line 24:
  
 
== 2. Activity==  
 
== 2. Activity==  
Activity will display the WebView with predefined URL. You need to specify the Url of your website here.
+
Activity will display the WebView with a predefined URL. You need to specify the URL of your website here.
  
 
'''File : MainActivity.java'''
 
'''File : MainActivity.java'''
Line 49: Line 51:
  
 
== 3. Android Manifest ==  
 
== 3. Android Manifest ==  
WebView required INTERNET permission, add below into AndroidManifest.xml.
+
WebView required INTERNET permission. Add the following code into AndroidManifest.xml.
  
 
<syntaxhighlight><uses-permission android:name="android.permission.INTERNET" /></syntaxhighlight>
 
<syntaxhighlight><uses-permission android:name="android.permission.INTERNET" /></syntaxhighlight>
Line 85: Line 87:
 
</code>
 
</code>
 
<br/>
 
<br/>
 
== Contribute ==
 
This is my first article at Nokia Community please free to edit this article to make it useful.
 
  
 
== Example application ==
 
== Example application ==
  
You can find the source code for an example from Nokia X WebView project at [https://github.com/ashishrathee17/NokiaX_WebView Github].
+
You can find the source code for an example in [https://github.com/ashishrathee17/NokiaX_WebView Github the Nokia X WebView project on Github].
  
This example is also available in Nokia Store. To find it, search for the application named "Proj Webview" published by Rathee.ashish.1712
+
This example was based on the Proj Webview app, published by Rathee.ashish.1712, in the Nokia Store.

Revision as of 22:28, 16 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.

427 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.

×