Practical No.1: UI Code
Practical No.1: UI Code
1
UI Code :-
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView3"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="96dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Longitude and Latitude"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/button"
android:layout_alignEnd="@+id/button" />
</RelativeLayout>
Source Code:-
package com.example.prashant.locationmsg;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;
public class
MainActivityextendsAppCompatActivityimplementsLocationListener {
private GoogleApiClientclient;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t1 = (TextView) findViewById(R.id.textView);
t2 = (TextView) findViewById(R.id.textView3);
t3 = (TextView) findViewById(R.id.textView2);
b1 = (Button) findViewById(R.id.button);
b1.setOnClickListener(new View.OnClickListener() {
locationManager= (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED&&ActivityCompat.checkSelfPermi
ssion(this, Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
locationManager.requestLocationUpdates(LocationManager.GPS_PROVI
DER, 0, 0, this);
client = new
GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
client.connect();
Action viewAction = Action.newAction(
Action.TYPE_VIEW,
“Main Page",
Uri.parse("http://host/path"),
Uri.parse("android-
app://com.example.prashant.locationmsg/http/host/path")
);
AppIndex.AppIndexApi.start(client, viewAction);
}
Output:-
Permission :-
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.prashant.locationmsg">
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
Practical No.2
UI Code:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res
/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.prashant.gpstrace.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView3"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="96dp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Longitude and Latitude"
android:id="@+id/button"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/button"
android:layout_alignEnd="@+id/button" />
</RelativeLayout>
Source Code:-
package com.example.prashant.gpstrace;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class
MainActivityextendsAppCompatActivityimplementsLocationListener {
t1 = (TextView) findViewById(R.id.textView);
t2 = (TextView) findViewById(R.id.textView3);
t3 = (TextView) findViewById(R.id.textView2);
b1 = (Button) findViewById(R.id.button);
b1.setOnClickListener(new View.OnClickListener() {
locationManager= (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED&&ActivityCompat.checkSelfPermi
ssion(this, Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
return; }
locationManager.requestLocationUpdates(LocationManager.GPS_PROVI
DER, 0, 0, this);
}
@Override
public void onLocationChanged(Location location) {
lat=location.getLatitude();
longg= location.getLongitude();
Log.d(""+lat,""+lat);
Log.d(""+longg,""+longg);
@Override
public void onProviderDisabled(String provider) {
Log.d("Latitude","disable");
}
@Override
public void onProviderEnabled(String provider) {
Log.d("Latitude","enable");
}
@Override
public void onStatusChanged(String provider, intstatus, Bundle
extras) {
Log.d("Latitude","status");
}
}
Output:-
Permission :-
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.prashant.gpstrace">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
2) XAMPP Server
3) Mysql-java connector
4) OpenGTS application.
http://www.opengts.org/
publicCloseableSimpleWarning()
{
//setBackground(Color.red);
//setForeground(Color.black);
setTitle("Warning");
setSize(frame_width, frame_height);
addWindowListener(this);
}
public void windowClosing (WindowEvent e)
{
System.exit(0);
}
public void windowClosed (WindowEvent e)
{
System.exit(0);
}
public void windowIconified (WindowEvent e)
{
System.exit(0);
}
public void windowDeiconified (WindowEvent e)
{
System.exit(0);
}
public void windowOpened (WindowEvent e)
{
System.exit(0);
}
public void windowActivated (WindowEvent e)
{
System.exit(0);
}
f.show();
}
}
Reference :-
http://www.dcs.gla.ac.uk/~johnson/teaching/hci-java/course.html
http://www.paneurouni.com/files/sk/projektesf/hci-design-gui-
programming-java-vyber.pdf
Practical No.6
Download Java Card Sdk from
http://www.oracle.com/technetwork/java/embedded/javacard/downloa
ds/javacard-sdk-2043229.html
Install in Netbeans as plugin :-
Tools -> Plugin
Create an application
Code:-
package classicapplet2;
importjavacard.framework.*;
protected ClassicApplet2() {
received = new byte[MAX_LENGTH];
register();
}