CSC-491L - Mobile Application Development Lab Manual Ver 2.0
CSC-491L - Mobile Application Development Lab Manual Ver 2.0
Student Name:
Class / Section:
Roll Number:
CGPA:
Email ID:
www.fui.edu.pk
http://www.fui.edu.pk/FURC/
PREPARED BY
Lab manual is prepared by Mr. Muhammad Asif under the supervision of Head of
Department in the year 2019. Revised in January 2020 by adding more experiments and
done some corrections.
GENERAL INSTRUCTIONS
a. Students are required to maintain the lab manual with them till the end of the
semester.
b. All readings, answers to questions and illustrations must be solved on the place
provided. If more space is required, then additional sheets may be attached.
c. It is the responsibility of the student to have the manual graded before deadlines as
given by the instructor
d. Loss of manual will result in re submission of the complete manual.
e. Students are required to go through the experiment before coming to the lab session.
Lab session details will be given in training schedule.
f. Students must bring the manual in each lab.
g. Keep the manual neat clean and presentable.
h. Plagiarism is strictly forbidden. No credit will be given if a lab session is plagiarized
and no re submission will be entertained.
i. Marks will be deducted for late submission.
j. You can use separate sheets for Lab exercises and attach them with the lab manuals.
VERSION HISTORY
Date Update By Details
January Muhammad Asif Version 1.0. Initial draft prepared and
2019 experiments outlined.
January Muhammad Asif Version 2.0. Addition of Introduction to IDE,
2020 Latest Application Development exercises and
Tasks with cross development platforms e.g.
Flutter
Aim:
To develop a Simple Android Application that uses GUI components, Font and Colors.
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:gravity="center"
android:text="Hello World!"
android:textSize="25sp"
android:textStyle="bold" />
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change font size"
android:textSize="25sp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:gravity="center"
android:text="Change color"
android:textSize="25sp" />
</LinearLayout>
• Now click on Design and your application will look as given below.
• Then delete the code which is there and type the code as given below.
package com.example.exno1;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
Output:
Thus a Simple Android Application that uses GUI components, Font and Colors is developed
and executed successfully.
Execute the above exercise of font size and color in Android studio and show the exact GUI
output? [2]
TASK 1.1
In the above example, Change the font styles of the text “Hello World!” by adding another
button?
Develop an android application to display current date and time on the Button widget. [6]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
To develop a Simple Android Application that uses Layout Managers and Event Listeners.
Procedure:
Creating a New project:
• Open Android Stdio and then click on File -> New -> New project.
• Then delete the code which is there and type the code as given below.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Details Form"
<GridLayout
android:id="@+id/gridLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:layout_marginBottom="200dp"
android:columnCount="2"
android:rowCount="3">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="0"
android:text="Name"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="0"
android:layout_column="1"
android:ems="10"/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="1"
android:layout_column="0"
android:text="Reg.No"
android:textSize="20sp"
android:gravity="center"/>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="1"
android:layout_column="1"
android:inputType="number"
android:ems="10"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2"
android:layout_column="0"
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_row="2"
android:layout_column="1"
android:spinnerMode="dropdown"/>
</GridLayout>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginBottom="150dp"
android:text="Submit"/>
</RelativeLayout>
• Now click on Design and your activity will look as given below.
• Then delete the code which is there and type the code as given below.
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="New Text"
android:textSize="30sp"/>
</LinearLayout>
• Now click on Design and your activity will look as given below.
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
String name,reg,dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
s= (Spinner) findViewById(R.id.spinner);
startActivity(i);
}
});
}
}
package com.example.exno2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
TextView t1,t2,t3;
String name,reg,dept;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
//Getting the Values from First Activity using the Intent received
name=i.getStringExtra("name_key");
reg=i.getStringExtra("reg_key");
dept=i.getStringExtra("dept_key");
}
}
Output:
Thus a Simple Android Application that uses Layout Managers and Event Listeners is
developed and executed successfully.
EXERCISE 2.1:
Execute the above exercise of Layout Manager and Event Listener in Android studio and show
the exact GUI output? [2]
Develop an android application to display Toast on clicking a button. This should be a customize
button which includes setGravity and setMargin?
Develop an android application By using Implicit and Explicit Intent. By using Implicit intent, A
web page should be open in a web browser. Also call 2nd activity from the first activity by using
explicit intent. [8]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Aim:
Procedure:
Creating a New project:
• Open Android Stdio and then click on File -> New -> New project.
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberDecimal"
android:textSize="20sp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="numberDecimal"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/Add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+"
android:textSize="30sp"/>
<Button
android:id="@+id/Sub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-"
android:textSize="30sp"/>
<Button
android:id="@+id/Mul"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="*"
android:textSize="30sp"/>
<Button
android:id="@+id/Div"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="/"
android:textSize="30sp"/>
</LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="Answer is"
android:textSize="30sp"
android:gravity="center"/>
</LinearLayout>
• Now click on Design and your application will look as given below.
• Then delete the code which is there and type the code as given below.
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// set a listener
Add.setOnClickListener(this);
Sub.setOnClickListener(this);
Mul.setOnClickListener(this);
Div.setOnClickListener(this);
}
@Override
public void onClick (View v)
{
float num1 = 0;
float num2 = 0;
float result = 0;
String oper = "";
// defines the button that has been clicked and performs the
corresponding operation
// write operation into oper, we will use it later for output
switch (v.getId())
{
case R.id.Add:
oper = "+";
result = num1 + num2;
break;
Output:
Execute the above exercise of Native Calculator in Android studio and show the exact GUI
output? [2]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
46 Android Application Development Manual
EXERCISE 4 – ANDROID APPLICATION TO DRAW BASIC
GRAPHICAL PRIMITIVES
Aim:
To develop a Simple Android Application that draws basic Graphical Primitives on the screen.
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
• Then delete the code which is there and type the code as given below.
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>
• Now click on Design and your application will look as given below.
• Then delete the code which is there and type the code as given below.
package com.example.exno4;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
//Creating a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
//Creating the Paint Object and set its color & TextSize
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(50);
Output:
Thus a Simple Android Application that draws basic Graphical Primitives on the screen is
developed and executed successfully.
EXERCISE 4.1:
Execute the above exercise of graphics in Android studio and show the exact GUI output? [2]
Develop an android application to display simple graphics i.e. Oval, Rectangle with different
colors.
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="110dp"
android:text="Enter Rollno:"
android:textSize="20sp" />
<EditText
android:id="@+id/Rollno"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="100dp"
android:inputType="number"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="160dp"
android:text="Enter Name:"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="210dp"
android:text="Enter Marks:"
android:textSize="20sp" />
<EditText
android:id="@+id/Marks"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="175dp"
android:layout_y="200dp"
android:inputType="number"
android:textSize="20sp" />
<Button
android:id="@+id/Insert"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="300dp"
android:text="Insert"
android:textSize="30dp" />
<Button
android:id="@+id/Delete"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="300dp"
android:text="Delete"
android:textSize="30dp" />
<Button
android:id="@+id/Update"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="25dp"
android:layout_y="400dp"
android:text="Update"
android:textSize="30dp" />
<Button
android:id="@+id/View"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_x="200dp"
<Button
android:id="@+id/ViewAll"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="500dp"
android:text="View All"
android:textSize="30dp" />
</AbsoluteLayout>
• Now click on Design and your application will look as given below.
package com.example.exno5;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
Rollno=(EditText)findViewById(R.id.Rollno);
Name=(EditText)findViewById(R.id.Name);
Marks=(EditText)findViewById(R.id.Marks);
Insert=(Button)findViewById(R.id.Insert);
Delete=(Button)findViewById(R.id.Delete);
Update=(Button)findViewById(R.id.Update);
View=(Button)findViewById(R.id.View);
ViewAll=(Button)findViewById(R.id.ViewAll);
Insert.setOnClickListener(this);
Delete.setOnClickListener(this);
Output:
Thus a Simple Android Application that makes use of Database is developed and
executed successfully.
EXERCISE 5.1:
Execute the above exercise of database in Android studio and show the exact GUI output? [10]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
• Now click on Design and your application will look as given below.
• Now include the INTERNET permissions in the AndroidManifest.xml file as shown below
• Then delete the code which is there and type the code as given below.
package com.example.exno6;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
79 Android Application Development Manual
import java.util.List;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
new MyAsyncTask().execute();
}
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
return null;
}
protected void onPostExecute(ArrayAdapter adapter)
{
adapter = new ArrayAdapter(MainActivity.this,
android.R.layout.simple_list_item_1, headlines);
setListAdapter(adapter);
}
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
Uri uri = Uri.parse((links.get(position)).toString());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
Output:
Thus Android Application that makes use of RSS Feed is developed and executed successfully.
EXERCISE 6.1:
Execute the above exercise of RSS feed in Android studio and show the exact GUI output? [02]
Develop an android application to read and write data on external storage. [08]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<ImageView
android:id="@+id/imageView"
android:layout_width="250dp"
android:layout_height="250dp"
android:layout_margin="50dp"
android:layout_gravity="center" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load Image 1" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
android:text="Load image 2" />
</LinearLayout>
• Now click on Design and your application will look as given below.
• Then delete the code which is there and type the code as given below.
package com.example.exno7;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity
{
ImageView img;
Button bt1,bt2;
bt1 = (Button)findViewById(R.id.button);
bt2= (Button) findViewById(R.id.button2);
img = (ImageView)findViewById(R.id.imageView);
bt1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override
public void run()
{
img.post(new Runnable()
{
@Override
public void run()
{
img.setImageResource(R.drawable.india1);
}
});
}
}).start();
}
});
bt2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
new Thread(new Runnable()
{
@Override
public void run()
{
img.post(new Runnable()
{
@Override
public void run()
{
img.setImageResource(R.drawable.india2);
}
});
}
}).start();
}
});
}
}
Output:
Result:
EXERCISE 6.1:
Execute the above exercise of multi threading in Android studio and show the exact GUI output?
[04]
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="30dp" />
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Write Data"
android:textSize="30dp" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Read data"
android:textSize="30dp" />
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
</LinearLayout>
• Now click on Design and your application will look as given below.
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<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" />
package com.example.exno9;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
write.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
read.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String message;
String buf = "";
try
{
File f = new File("/sdcard/myfile.txt");
FileInputStream fin = new FileInputStream(f);
BufferedReader br = new BufferedReader(new
InputStreamReader(fin));
while ((message = br.readLine()) != null)
{
buf += message;
}
e1.setText(buf);
br.close();
fin.close();
Toast.makeText(getBaseContext(),"Data Recived from
SDCARD",Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
Toast.makeText(getBaseContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
}
}
});
clear.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
e1.setText("");
}
});
}
Output:
Result:
Thus Android Application that writes data to the SD Card is developed and
executed successfully.
Develop an android application to read and write data on Internal storage. [10]
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:textSize="30sp" />
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textSize="30sp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:layout_gravity="center"
android:text="Notify"
android:textSize="30sp"/>
</LinearLayout>
• Now click on Design and your application will look as given below.
• Then delete the code which is there and type the code as given below.
package com.example.exno10;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
notify.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Intent intent = new Intent(MainActivity.this,
SecondActivity.class);
PendingIntent pending =
PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
Notification noti = new
Notification.Builder(MainActivity.this).setContentTitle("New
Message").setContentText(e.getText().toString()).setSmallIcon(R.mipmap.ic_laun
cher).setContentIntent(pending).build();
NotificationManager manager = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
manager.notify(0, noti);
}
});
}
}
Output:
Thus Android Application that creates an alert upon receiving a message is developed and
executed successfully.
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
121 Android Application Development Manual
EXERCISE 10 – ANDROID APPLICATION THAT CREATES
ALARM CLOCK
Aim:
Procedure:
Creating a New project:
• Open Android Studio and then click on File -> New -> New project.
<TimePicker
android:id="@+id/timePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dp"
android:checked="false"
android:onClick="OnToggleClicked" />
</LinearLayout>
• Now click on Design and your application will look as given below.
• Now change the activity tag to receiver tag in the AndroidManifest.xml file as shown below
<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" />
</manifest>
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import java.util.Calendar;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
alarmTimePicker = (TimePicker) findViewById(R.id.timePicker);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
}
public void OnToggleClicked(View view)
{
long time;
if (((ToggleButton) view).isChecked())
{
Toast.makeText(MainActivity.this, "ALARM ON",
Toast.LENGTH_SHORT).show();
Calendar calendar = Calendar.getInstance();
time=(calendar.getTimeInMillis()-
(calendar.getTimeInMillis()%60000));
if(System.currentTimeMillis()>time)
{
if (calendar.AM_PM == 0)
time = time + (1000*60*60*12);
else
time = time + (1000*60*60*24);
}
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, time, 10000,
pendingIntent);
}
else
{
alarmManager.cancel(pendingIntent);
Toast.makeText(MainActivity.this, "ALARM OFF",
Toast.LENGTH_SHORT).show();
}
}
}
• Then delete the code which is there and type the code as given below.
package com.example.exno11;
Output:
Thus Android Application that creates Alarm Clock is developed and executed successfully.
Develop an android application to Alarm a clock and a button to off the alarm.
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Android analog and digital clocks are used to show time in android application.
Android DigitalClock is the subclass of TextView class. Since Android API level 17, it is
deprecated. You are recommended to use TextClock Instead.
The AnalogClock was deprecated in API level 23. This widget is no longer supported. Instead if
you want to use AnalogClock in your application you need to hard code. It does not appear in
API level 27 to drag from palette.
In android, you need to drag analog and digital clocks from the pallet to display analog and
digital clocks.
activity_main.xml
Now, drag the analog and digital clocks, now the xml file will look like this.
File: activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/an
droid"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.javatpoint.com.analogdigital.MainActivity">
<AnalogClock
android:id="@+id/analogClock1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="136dp"
android:layout_marginTop="296dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<DigitalClock
android:id="@+id/digitalClock1"
android:layout_width="wrap_content"
Activity class
File: MainActivity.java
package example.javatpoint.com.analogdigital;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TASK 11.1
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
We can play and control the audio files in android by the help of MediaPlayer class.
Here, we are going to see a simple example to play the audio file. In the next page, we will see
the example to control the audio playback like start, stop, pause etc.
MediaPlayer class
Activity class
Let's write the code of to play the audio file. Here, we are going to play maine.mp3 file located
inside the sdcard/Music directory.
File: MainActivity.java
package com.example.audiomediaplayer1;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.VideoView;
@Override
super.onCreate(savedInstanceState);
try{
mp.prepare();
mp.start();
}catch(Exception e){e.printStackTrace();}
@Override
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
Let's see a simple example to start, stop and pause the audio play.
activity_main.xml
Drag three buttons from pallete to start, stop and pause the audio play. Now the xml file will look
like this:
<RelativeLayout xmlns:androclass="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=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
144 Android Application Development Manual
android:layout_below="@+id/textView1"
android:layout_marginTop="48dp"
android:text="start" />
<Button
android:id="@+id/button2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button1"
android:layout_toRightOf="@+id/button1"
android:text="pause" />
<Button
android:id="@+id/button3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button2"
android:layout_toRightOf="@+id/button2"
android:text="stop" />
</RelativeLayout>
Activity class
Let's write the code to start, pause and stop the audio player.
145 Android Application Development Manual
File: MainActivity.java
package com.example.audioplay;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
Button start,pause,stop;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
start=(Button)findViewById(R.id.button1);
pause=(Button)findViewById(R.id.button2);
stop=(Button)findViewById(R.id.button3);
try{
146 Android Application Development Manual
//you can change the path, here path is external directory(e.g. sdcard) /Music/maine
.mp3
mp.setDataSource(Environment.getExternalStorageDirectory().getPath()+"/Music/main
e.mp3");
mp.prepare();
}catch(Exception e){e.printStackTrace();}
start.setOnClickListener(new OnClickListener() {
@Override
mp.start();
});
pause.setOnClickListener(new OnClickListener() {
@Override
mp.pause();
});
stop.setOnClickListener(new OnClickListener() {
@Override
mp.stop();
});
147 Android Application Development Manual
}
Output:
TASK 12.1
Develop an android application to Play, Stop and Pause audio and video files.
Develop an android application to record from media recorder from your mobile. [05]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
Android provides facility to integrate Google map in our application. Google map displays your
current location, navigate location direction, search location etc. We can also customize Google
map according to our requirement.
There are four different types of Google maps, as well as an optional to no map at all. Each of
them gives different view on map. These maps are as follow:
1. Normal: This type of map displays typical road map, natural features like river and some features
build by humans.
2. Hybrid: This type of map displays satellite photograph data with typical road maps. It also
displays road and feature labels.
3. Satellite: Satellite type displays satellite photograph data, but doesn't display road and feature
labels.
4. Terrain: This type displays photographic data. This includes colors, contour lines and labels and
perspective shading.
5. None: This type displays an empty grid with no tiles loaded.
Let's create an example of Google map integrating within our app. For doing this we select
Google Maps Activity.
Copy the URL from google_map_api.xml file to generate Google map key.
MapsActivity.java
To get the GoogleMap object in our MapsActivity.java class we need to implement the
OnMapReadyCallback interface and override the onMapReady() callback method.
package example.com.mapexample;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
@Override
super.onCreate(savedInstanceState);
156 Android Application Development Manual
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
@Override
mMap = googleMap;
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
Required Permission
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="example.com.mapexample">
<!--
Google Maps Android API v2, but you must specify either coarse or fine
-->
<uses-
permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
build.gradel
1. dependencies {
2. implementation fileTree(dir: 'libs', include: ['*.jar'])
3. implementation 'com.android.support:appcompat-v7:26.1.0'
4. implementation 'com.google.android.gms:play-services-maps:11.8.0'
5. testImplementation 'junit:junit:4.12'
6. androidTestImplementation 'com.android.support.test:runner:1.0.1'
7. androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
8. }
Output
Develop an android application to search your current location and add marker to it. [05]
Develop an android application to search your current location using Geo coder. [05]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
In android, you can convert your text into speech by the help of TextToSpeech class. After
completion of the conversion, you can playback or create the sound file.
TextToSpeech.OnInitListener Interface
activity_main.xml
Drag one textview, one edittext and one button for the layout. Now the activity_main.xml file
will look like this:
File: activity_main.xml
<RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="77dp"
android:layout_marginTop="42dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginLeft="59dp"
android:layout_marginTop="39dp"
android:text="Speak" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
164 Android Application Development Manual
android:text="Enter Text:" />
</RelativeLayout>
Activity class
File: MainActivity.java
package com.example.texttospeech;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import java.util.Locale;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
TextToSpeech.OnInitListener {
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buttonSpeak.setOnClickListener(new View.OnClickListener() {
@Override
speakOut();
});
@Override
if (tts != null) {
166 Android Application Development Manual
tts.stop();
tts.shutdown();
super.onDestroy();
@Override
if (status == TextToSpeech.SUCCESS) {
if (result == TextToSpeech.LANG_MISSING_DATA
|| result == TextToSpeech.LANG_NOT_SUPPORTED) {
} else {
buttonSpeak.setEnabled(true);
speakOut();
} else {
@Override
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
TASK 14.1
Make an app using the above text to speech exercise and display output (as a screen shot) and
code also.
Develop an android application to read and save data to some external source such as SD card.
[10]
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
171 Android Application Development Manual
EXERCISE 15 – ANDROID SENSOR TUTORIAL
Sensors can be used to monitor the three-dimensional device movement or change in the
environment of the device.
Types of Sensors
1) Motion Sensors
These are used to measure acceleration forces and rotational forces along with three axes.
2) Position Sensors
3) Environmental Sensors
These are used to measure the environmental changes such as temperature, humidity etc.
Android sensor api provides many classes and interface. The important classes and interfaces of
sensor api are as follows:
You can get the instance of SensorManager by calling the method getSystemService() and
passing the SENSOR_SERVICE constant in it.
1. SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
2) Sensor class
The android.hardware.Sensor class provides methods to get information of the sensor such as
sensor name, sensor type, sensor resolution, sensor type etc.
3) SensorEvent class
Its instance is created by the system. It provides information about the sensor.
4) SensorEventListener interface
It provides two call back methods to get information when sensor values (x,y and z) change or
sensor accuracy changes.
1. A sensor example that prints x, y and z axis values. Here, we are going to see that.
2. A sensor example that changes the background color when device is shuffled. Click for changing
background color of activity sensor example
activity_main.xml
File: activity_main.xml
<RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="92dp"
android:layout_marginTop="114dp"
android:text="TextView" />
</RelativeLayout>
Activity class
Let's write the code that prints values of x axis, y axis and z axis.
File: MainActivity.java
package com.example.sensorsimple;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;
import android.hardware.SensorManager;
import android.hardware.SensorEventListener;
import android.hardware.SensorEvent;
import java.util.List;
SensorManager sm = null;
List list;
};
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sm = (SensorManager)getSystemService(SENSOR_SERVICE);
textView1 = (TextView)findViewById(R.id.textView1);
list = sm.getSensorList(Sensor.TYPE_ACCELEROMETER);
175 Android Application Development Manual
if(list.size()>0){
}else{
@Override
if(list.size()>0){
sm.unregisterListener(sel);
super.onStop();
TASK 15.1
Execute the Mobile sensor code and show the output of the program.
https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio
https://www.youtube.com/playlist?list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E
Https://www.udemy.com/java-tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/
178 Android Application Development Manual
EXERCISE 16 – CROSS-PLATFORM TOOLS FOR APP
DEVELOPMENT (ANDROID, IOS AND WINDOWS PHONE)
Today startups and SMEs find cross-platform as an excellent form of technology to develop an
app on multiple platforms like Android, iOS, and Windows simultaneously.
This means by building a single app you can target both Android and iOS, thus, maximizing your
reach to the target audience.
In fact, the cross-platform application development market surpassed the figure of $7.9
in 2019.
Ideally, cross-platform technology delivers native-like apps because of the advent of advanced
tools and technologies that allow developers to build apps that may appear similar to native apps.
Also, in such a scenario when the number of apps in the Google Play Store was most recently
placed at around $2.6 million apps in March 2019. Businesses wouldn’t want to risk missing
their presence on Google play store or any other platform.
Budgeting always an issue for businesses if they go for native apps, this is where cross-platform
technology has emerged as the premium choice for businesses that aim to build their app
multiple platforms.
1. Adobe PhoneGap
PhoneGap is owned by Adobe and is one of the best cross-platform development tools to use
in 2019. It’s based on the open source framework Apache Cordova that gives you access to
complete set of PhoneGap toolset which helps streamline the app development process and
include the options:
Debugging tools allow you to inspect HTML, CSS, and debug codes in JavaScript. Here is the
list of tools:
Steps to Use:
Steps to Use:
179 Android Application Development Manual
1. Make sure your Android test device supports all the developer options.
2. Now launch your Google Chrome web browser.
3. Look for chrome://inspect in Chrome.
4. Select PhoneGap Application on your device.
5. Developer tools will launch.
One of the reasons why I am suggesting PhoneGap is because anyone can learn how to use their
tools, even if you don’t have experience of using them. PhoneGap takes care of the development
process by compiling all your work in the Cloud, so you don’t need to maintain native SDKs.
2. Appcelerator
Appcelerator is a cross-platform mobile app development platform that helps get your app
ready in a faster way by simplifying the whole process. By using a single JavaScript code you
can build native-like apps and mobile apps with cloud-like performance. Another top benefit of
Appcelerator is their quality as it can be used for building apps for any device or operating
system.
The tool also makes it easy for you to use and test your apps using the automated mobile tests
that allow you to measure your app usage and results of your app project. You can detect bugs,
crashes, and also make some adjustments to improve the overall performance of your app.
With Appcelerator, you will be provided with access to Hyperloop that is one of the best cross-
platform APIs for the multi-platform application development.
3. Corona
Corona is free to use cross-platform app development tool that primarily used in 2d games
as it’s great to use for high-quality graphics and high-speed development of games.
4. React Native
React Native is unquestionably the best platform to use for cross-platform app development
because it interprets your source code and convert it to the native elements in less time. Both
Facebook and Instagram have used React Native to build their native apps that are the most used
applications of the world. So, you can trust on React Native.
5. Xamarin
The best part of Xamarin cross-platform tool is that all the apps built on it look and feel like
native apps that is because it uses the native interfaces that work the same way a user wants to
use them.
With Xamarin, you can give your app a platform-specific hardware boosts to achieve the
performance similar to native apps. Also, most of your coding approx. 75% will be the same,
regardless of the platform you’re building your mobile application for. Xamarin works on a
single code by identifying it and accelerates the process for cross-platform mobile app
development.
Xamarin works on both Mac and PC systems and offers you tools such as debugging, UI design
tool, and code editing.
6. Qt
If your app is not performing well and you want to rework on it, you can easily make changes to
your app using Qt that will automatically make all the changes applied to your app. This software
tool also allows you to see how your app is performing on different platforms. Moreover, it’s
easy to use and don’t have a complex interface like some other cross-platform tools I’ve seen.
7. Sencha
In addition, Sencha provides you with the “Themer” to create reusable themes by customizing
themes built on iOS, Ext JS, ExtAngular, and ExtReact. Sencha offers a data visualization table
that makes it easier for you to track your app information. This also makes it possible for you to
organize your app content and how your content is displayed on the browser, device, and
screen size.
8. Unity3D
This cross-platform app development tool is so popular because of its graphics quality that is
absolutely incredible. It’s so easy to use this tool and you can use it for more than just a mobile
app. With Unity3D tool you can export your app or games to 17 platforms that include — iOS,
Android, Windows, Xbox, PlayStation, Linux, Web, and Wii.
Unity3d can also be used to track user analytics and share your app on social networks. You can
also connect with the network of Unity3D developers called Unity Connect to find help and get
your questions answered if you’re having tech issues with coding or something else.
9. 5App
5Apps uses HTML5 and JavaScript for coding of apps and emphasis on the security of app data.
The tool allows you to quickly create relevant content to support your employees’ learning and
performance.
The finished app is compatible with both Android and iOS devices, so you can choose
accordingly as per your company’s needs.
10. FLUTTER
Flutter is on the bleeding edge of cross-platform development, and it deserves special attention.
It’s so close to the “code once, deploy twice” phenomenon, by completely sidestepping the
native platforms. And it’s quickly gaining speed in the developer community.
The way Flutter works is by compiling Dart source code to native code, which runs on the Dart
virtual machine. You can compare this to Xamarin, which runs native code directly on the
smartphone hardware, and to React Native, which runs interpreted JavaScript code in a native
app.
A particularly interesting feature of Flutter is called Hot Reload. With Hot Reload, changes to the
source code of an app can be directly injected at runtime. It’s like reloading a web page, without
needing to recompile the entire app. Hot Reload also retains the state of the app, so you can code
and interact with the app at the same time.
Similarly to other tools, Flutter provides shared code for platform-specific features such as
Android’s and Apple’s UI design, as well as the option to build platform-specific plugins.
Platform-specific APIs and SDKs can be used natively.
EXERCISE 16.1:
Develop a Digital Counter app in Flutter. Run the below program and show the output. [05]
DART:
import 'package:flutter/material.dart';
void initState() {
super.initState();
val = 0;
}
void change() {
setState(() {
val += 1;
});
}
Develop a spinning image app in Flutter. Run the below program and show the output. [05]
DART:
import 'package:flutter/material.dart';
@override
void initState() {
super.initState();
controller = AnimationController(
duration: Duration(seconds: 1),
vsync: this,
);
animation = CurvedAnimation(
parent: controller,
curve: Curves.easeInOutCubic,
).drive(Tween(begin: 0, end: 2));
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
190 Android Application Development Manual
return GestureDetector(
onTap: () {
controller
..reset()
..forward();
},
child: RotationTransition(
turns: animation,
child: Stack(
children: [
Positioned.fill(
child: FlutterLogo(),
),
Center(
child: Text(
'Click me!',
style: TextStyle(
fontSize: 60.0,
fontWeight: FontWeight.bold, ), ), ), ], ), ), ); }}