Hi All,
With this post, I am trying to develop a simple client server application which runs android application in the client side and ASP.NET MVC application in the server side.
As the first application of this big project, now I am going to tell you how to develop your Android client application.
Requirements for this application.
Then set project name as "AndroidClient" and click next. In the "select build target wizard", choose a sdk to target and click next. I used Android 2.3.3 here. Give "com.AndroidClient.mobile" as package name and click finished. Please make sure "create activity" option is selected.
Here we go. Now we have our Android client project. Please add below dew lines of codes to the "onCreate" which resides in src/com.clientServerApp.mobile/AndroidClientActivity.
Now we are going to run this application using Phonegap. Here we use Phonegap to convert our html file for our Android phone. Please download this the file which include phonegap-1.4.1.jar and other files need for this application from this link.
Now right click on the project and go to BuildPath --> Add External Archieves.. and select location for the phonegap-1.4.1.jar in side downloaded folder. Now you can see it under "Referenced Libraries". Now just copy phonegap-1.4.1.js file which is inside downloaded folder and easily paste to "www" directory by right clicking "www" folder.
Now go to the "res" directory and create a new directory named "xml". Then you should copy both phonegap.xml and plugins.xml from the downloaded folder and paste them in to the created "xml" folder.
As the final thing, you have to do changes in to the Android.manifest file. Please add below code to the Android.manifest file in your project.
Here we go..Now you can run our client application by right click on the project, Run As --> Android Application. You can see the output as below.
Now we want to get texts which will be entered by username and password fields and send them to the server for granting access. We will use java script and Ajax to send client request to the server. We will meet with my next post of how to send client request to the server and its format. We will use Json for send data objects to the server.
Please give you comments about this article. Your valuable comments are really appreciated and they will help me to make much better blog posts than this.
Thank you..!!
With this post, I am trying to develop a simple client server application which runs android application in the client side and ASP.NET MVC application in the server side.
As the first application of this big project, now I am going to tell you how to develop your Android client application.
Requirements for this application.
- Install Java
- Eclipse IDE
- Installed Android and configured it with your Eclipse
Then set project name as "AndroidClient" and click next. In the "select build target wizard", choose a sdk to target and click next. I used Android 2.3.3 here. Give "com.AndroidClient.mobile" as package name and click finished. Please make sure "create activity" option is selected.
Here we go. Now we have our Android client project. Please add below dew lines of codes to the "onCreate" which resides in src/com.clientServerApp.mobile/AndroidClientActivity.
Now you should create a new "www" folder inside "assets" folder in your project. For that just right click on assets folder and New -> Folder. Then create another folder named "html" inside www directory and place below html file in the html folder.super.onCreate(savedInstanceState); super.setBooleanProperty("keepRunning", false); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); super.setIntegerProperty("loadUrlTimeoutValue", 40000); super.loadUrl("file:///android_asset/www/html/login.html");
<!DOCTYPE html>
<html>
<body>
<form action="" method="post">
<div id="errorstatus"></div>
<br />
<label>Username:</label>
<input type="text" name="email" id="username"/>
<br />
<label>Password:</label>
<input type="password" name="name" id="password"/>
<br />
<a href="" onclick="">Forgot Password ?</a>
<br /><br />
<input type="button" value="Log in" id ="loginButton" name="loginButton" onclick=""/>
<input type="button" value="Sign Up" id ="signupButton" name="signUpButton" onclick=""/>
</form>
</body>
</html>
Now we are going to run this application using Phonegap. Here we use Phonegap to convert our html file for our Android phone. Please download this the file which include phonegap-1.4.1.jar and other files need for this application from this link.
Now right click on the project and go to BuildPath --> Add External Archieves.. and select location for the phonegap-1.4.1.jar in side downloaded folder. Now you can see it under "Referenced Libraries". Now just copy phonegap-1.4.1.js file which is inside downloaded folder and easily paste to "www" directory by right clicking "www" folder.
Now go to the "res" directory and create a new directory named "xml". Then you should copy both phonegap.xml and plugins.xml from the downloaded folder and paste them in to the created "xml" folder.
As the final thing, you have to do changes in to the Android.manifest file. Please add below code to the Android.manifest file in your project.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AndroidClient.mobile"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name="com.AndroidClient.mobile.AndroidClientActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenLayout|keyboardHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Here we go..Now you can run our client application by right click on the project, Run As --> Android Application. You can see the output as below.
Now we want to get texts which will be entered by username and password fields and send them to the server for granting access. We will use java script and Ajax to send client request to the server. We will meet with my next post of how to send client request to the server and its format. We will use Json for send data objects to the server.
Please give you comments about this article. Your valuable comments are really appreciated and they will help me to make much better blog posts than this.
Thank you..!!