5.
Develop an application that makes use of Notification Manager
6. Implement an application that uses Multi-threading
1.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableLayout
android:layout_width="395dp"
android:layout_height="715dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Multithreading Application"
tools:layout_editor_absoluteX="176dp"
tools:layout_editor_absoluteY="16dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="value from thread1:"
tools:layout_editor_absoluteX="158dp"
tools:layout_editor_absoluteY="41dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditText
android:id="@+id/no1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="0"
tools:layout_editor_absoluteX="98dp"
tools:layout_editor_absoluteY="49dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Value from thread2"
tools:layout_editor_absoluteX="156dp"
tools:layout_editor_absoluteY="108dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditText
android:id="@+id/no2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="0"
tools:layout_editor_absoluteX="78dp"
tools:layout_editor_absoluteY="124dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="start"
tools:layout_editor_absoluteX="161dp"
tools:layout_editor_absoluteY="182dp"
android:onClick="start"/>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
</TableLayout>
</[Link]>
[Link]
package [Link].bii_exno_7;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
Handler tss_handler=new Handler();
EditText tss_tv1,tss_tv2;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
tss_tv1=(EditText)findViewById([Link].no1);
tss_tv2=(EditText)findViewById([Link].no2);
}
public void thread1()
{
tss_tv1.setText([Link]([Link](tss_tv1.getText().toString())+1));
tss_handler.postDelayed(run,500);
}
public void thread2()
{
tss_tv2.setText([Link]([Link](tss_tv2.getText().toString())+1));
tss_handler.postDelayed(run,500);
}
public void start(View view)
{
tss_handler.postDelayed(run,500);
}
Runnable run=new Runnable() {
@Override
public void run() {
thread1();
thread2();
}
};
}
7. Develop a native application that uses GPS location information
1.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:id="@+id/lat"
android:textSize="20sp"
android:text="Latitude :"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/lon"
android:textSize="20sp"
android:text="Longitude :"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
LocationManager locationManager;
LocationListener locationListener;
TextView latitude;
TextView longitude;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
latitude = (TextView) findViewById([Link]);
longitude = (TextView) findViewById([Link]);
locationManager = (LocationManager)
[Link](Context.LOCATION_SERVICE);
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
[Link]("Latitude :"+[Link]());
[Link]("Longitude :"+[Link]());
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
};
if ([Link].SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission([Link].ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
checkSelfPermission([Link].ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
}
[Link](LocationManager.GPS_PROVIDER, 0, 0,
locationListener);
}
}
8. Implement an application that writes data to the SD card.
1.activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableLayout
android:layout_width="395dp"
android:layout_height="715dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
tools:layout_editor_absoluteX="162dp"
tools:layout_editor_absoluteY="32dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditText
android:id="@+id/write"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
tools:layout_editor_absoluteX="98dp"
tools:layout_editor_absoluteY="49dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Write"
tools:layout_editor_absoluteX="130dp"
tools:layout_editor_absoluteY="99dp"
android:onClick="write"/>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="146dp"
tools:layout_editor_absoluteY="147dp"
android:onClick="read"/>
</TableLayout>
</[Link]>
[Link]
package [Link].bii_exno_8;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
EditText text=(EditText) findViewById([Link]);
}
public void write(View view)
{
try
{
FileOutputStream fout=openFileOutput("[Link]",MODE_PRIVATE);
OutputStreamWriter writer1=new OutputStreamWriter(fout);
EditText text=(EditText) findViewById([Link]);
[Link]([Link]().toString());
[Link]();
[Link](getBaseContext(),"File saved
sucessfully",Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
}
}
public void read(View view)
{
try {
FileInputStream filein = openFileInput("[Link]");
InputStreamReader reader=new InputStreamReader(filein);
char[] inputbuffer=new char[1000];
String txt="";
int charread;
while((charread=[Link](inputbuffer))>0)
{
String read=[Link](inputbuffer,0,charread);
txt+=read;
}
[Link]();
[Link](getBaseContext(),txt,Toast.LENGTH_LONG).show();
}
catch (Exception e)
{
}
}
}