├── 2D Shapes
├── 2Ddiagram
│ ├── activity_main.xml
│ └── MainActivity.java
└── 2Ddiagram1
│ ├── activity_main.xml
│ └── MainActivity.java
├── Layouts
├── Vertical
│ ├── MainActivity.java
│ └── activity_main.xml
└── Horizontal
│ ├── MainActivity.java
│ └── activity_main.xml
├── Location Based Services
├── activity_main.xml
├── MainActivity.java
└── GPStrace.java
├── Intent
├── activity_main2.xml
├── MainActivity2.java
├── activity_main.xml
└── MainActivity.java
├── Notification Messages
├── activity_main.xml
└── MainActivity.java
├── Multithreading
├── activity_main.xml
└── MainActivity.java
├── Count vowels
├── activity_main.xml
└── MainActivity.java
├── Email
├── MainActivity.java
└── activity_main.xml
├── Change Font Size and Color
├── MainActivity.java.java
└── activity_main.xml
├── README.md
├── Billing
├── MainActivity.java
└── activity_main.xml
├── ArithmeticCalculator
├── activty_main.xml
└── MainActivity.java
└── Database Connectivity
├── activity_main.xml
└── MainActivity.java
/2D Shapes/2Ddiagram/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Layouts/Vertical/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.vertical;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | }
14 | }
--------------------------------------------------------------------------------
/Layouts/Horizontal/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.horizontal;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | }
14 | }
--------------------------------------------------------------------------------
/Location Based Services/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
14 |
--------------------------------------------------------------------------------
/Intent/activity_main2.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/Notification Messages/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/2D Shapes/2Ddiagram1/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
--------------------------------------------------------------------------------
/Multithreading/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
18 |
23 |
--------------------------------------------------------------------------------
/Intent/MainActivity2.java:
--------------------------------------------------------------------------------
1 | package com.example.fintent;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 | import androidx.appcompat.app.ActionBar;
8 | import androidx.appcompat.app.AppCompatActivity;
9 |
10 | public class MainActivity2 extends AppCompatActivity {
11 | @Override
12 | protected void onCreate(Bundle savedInstanceState) {
13 | super.onCreate(savedInstanceState);
14 | setContentView(R.layout.activity_main2);
15 | //actionbar title
16 | ActionBar actionBar = getSupportActionBar();
17 | actionBar.setTitle("Second Activity");
18 | //intent to get data
19 | Intent intent = getIntent();
20 | String name = intent.getStringExtra("NAME");
21 | String email = intent.getStringExtra("EMAIL");
22 | String phone = intent.getStringExtra("PHONE");
23 | //TextView
24 | TextView mResultTv = findViewById(R.id.resultTv);
25 | //setText
26 | mResultTv.setText("Name: "+name+"\nEmail: "+email+ "\nPhone: "+phone);
27 | }
28 | }
--------------------------------------------------------------------------------
/Count vowels/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
22 |
30 |
--------------------------------------------------------------------------------
/Location Based Services/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.location1;
2 | import android.app.Activity;
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import android.widget.Toast;
7 | public class MainActivity extends Activity {
8 | Button btnShowLocation;
9 | GPStrace gps;
10 | @Override
11 | public void onCreate(Bundle savedInstanceState) {
12 | super.onCreate(savedInstanceState);
13 | setContentView(R.layout.activity_main);
14 | btnShowLocation=(Button)findViewById(R.id.show_Location);
15 | btnShowLocation.setOnClickListener(new View.OnClickListener() {
16 | @Override
17 | public void onClick(View v) {
18 | gps=new GPStrace(MainActivity.this);
19 | if(gps.canGetLocation()){
20 | double latitude=gps.getLatitude();
21 | double longitude=gps.getLongtiude();
22 | Toast.makeText(getApplicationContext(),"Dhanavidhya your Location is \nLat:"+latitude+"\nLong:"+longitude, Toast.LENGTH_LONG).show();
23 | }
24 | else
25 | {
26 | gps.showSettingAlert();
27 | }
28 | }
29 | });
30 | }
31 | }
--------------------------------------------------------------------------------
/Intent/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
17 |
23 |
29 |
34 |
--------------------------------------------------------------------------------
/Email/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.email;
2 | import androidx.appcompat.app.AppCompatActivity;
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 |
10 | public class MainActivity extends AppCompatActivity {
11 |
12 | EditText to;
13 | EditText subject;
14 | EditText msg;
15 | Button snd;
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | to=findViewById(R.id.tofield);
21 | subject=findViewById(R.id.subfield);
22 | msg=findViewById(R.id.msgfield);
23 | snd=findViewById(R.id.snd);
24 |
25 | snd.setOnClickListener(new View.OnClickListener() {
26 | @Override
27 | public void onClick(View v) {
28 | String tolst=to.getText().toString();
29 | String[] toarr=tolst.split(",");
30 |
31 | String subj=subject.getText().toString();
32 | String msgg=msg.getText().toString();
33 |
34 | Intent i=new Intent(Intent.ACTION_SEND);
35 | i.putExtra(Intent.EXTRA_EMAIL,toarr);
36 | i.putExtra(Intent.EXTRA_SUBJECT,subj);
37 | i.putExtra(Intent.EXTRA_TEXT,msgg);
38 |
39 | i.setType("message/rfc822");
40 | startActivity(Intent.createChooser(i,"Choose an E-mail Provider"));
41 | }
42 | });
43 |
44 | }
45 | }
--------------------------------------------------------------------------------
/Intent/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.fintent;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.EditText;
9 | import androidx.appcompat.app.ActionBar;
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 |
13 | public class MainActivity extends AppCompatActivity {
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | //actionbar title
19 | ActionBar actionBar = getSupportActionBar();
20 | actionBar.setTitle("First Activity");
21 | //EditText
22 | final EditText mNameEt = findViewById(R.id.nameEt);
23 | final EditText mEmailEt = findViewById(R.id.emailEt);
24 | final EditText mPhoneEt = findViewById(R.id.phoneEt);
25 | //Button
26 | Button mSaveBtn = findViewById(R.id.saveBtn);
27 | //button click listener
28 | mSaveBtn.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View view) {
31 | //get data from edit text
32 | String name = mNameEt.getText().toString();
33 | String email = mEmailEt.getText().toString();
34 | String phone = mPhoneEt.getText().toString();
35 | //activity intent
36 | Intent intent = new Intent(MainActivity.this,MainActivity2.class);
37 | intent.putExtra("NAME", name);
38 | intent.putExtra("EMAIL", email);
39 | intent.putExtra("PHONE", phone);
40 | startActivity(intent);
41 | }
42 | });
43 | }
44 | }
--------------------------------------------------------------------------------
/2D Shapes/2Ddiagram1/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.a2ddiagram1;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.Path;
9 | import android.os.Bundle;
10 | import android.view.View;
11 | public class MainActivity extends AppCompatActivity {
12 | DemoView demoview;
13 | Paint paint=new Paint();
14 | Path path=new Path();
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | demoview=new DemoView(this);
19 | setContentView(demoview);
20 | }
21 | private class DemoView extends View{
22 | public DemoView(Context context){
23 | super(context);
24 | }
25 | protected void onDraw(Canvas canvas){
26 | super.onDraw(canvas);
27 | paint.setStyle(Paint.Style.FILL);
28 | paint.setColor(Color.WHITE);
29 | canvas.drawPaint(paint);
30 | //circle border
31 | paint.setAntiAlias(false);
32 | paint.setColor(Color.BLACK);
33 | canvas.drawCircle(500,700,410,paint);
34 | //circle
35 | paint.setAntiAlias(false);
36 | paint.setColor(Color.YELLOW);
37 | canvas.drawCircle(500,700,400,paint);
38 | //left eye
39 | paint.setAntiAlias(false);
40 |
41 | paint.setColor(Color.BLACK);
42 | canvas.drawOval(300,450,400,650,paint);
43 | //right eye
44 | paint.setAntiAlias(false);
45 | paint.setColor(Color.BLACK);
46 | canvas.drawOval(600,450,700,650,paint);
47 | //smile
48 | paint.setColor(Color.RED);
49 | canvas.drawArc(300,700,700,900,180,-180,false,paint);
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/Notification Messages/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.notification;
2 | import androidx.appcompat.app.AppCompatActivity;
3 | import android.annotation.SuppressLint;
4 | import android.os.Bundle;
5 | import androidx.core.app.NotificationCompat;
6 | import androidx.core.app.NotificationManagerCompat;
7 | import android.app.Notification;
8 | import android.app.NotificationChannel;
9 | import android.app.NotificationManager;
10 | import android.os.Build;
11 | import android.view.View;
12 | import android.widget.Button;
13 | public class MainActivity extends AppCompatActivity {
14 | Button notifyBtn;
15 | @SuppressLint("MissingInflatedId")
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | notifyBtn = (Button) findViewById(R.id.notify_btn);
21 | if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
22 | NotificationChannel channel = new NotificationChannel("My Notification", "My Notification", NotificationManager.IMPORTANCE_DEFAULT);
23 | NotificationManager manager = getSystemService(NotificationManager.class);
24 | manager.createNotificationChannel(channel);
25 | }
26 | notifyBtn.setOnClickListener(new View.OnClickListener() {
27 | @SuppressLint("MissingPermission")
28 | @Override
29 | public void onClick(View v) {
30 | NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this, "My Notification");
31 | builder.setContentTitle("Dhanavidhya C");
32 | builder.setContentText("Hello, Notification from Dhanavidhya");
33 | builder.setSmallIcon(R.drawable.ic_launcher_background);
34 | builder.setAutoCancel(true);
35 | NotificationManagerCompat managerCompat = NotificationManagerCompat.from(MainActivity.this);
36 | managerCompat.notify(1,builder.build());
37 | }
38 | });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Count vowels/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.countvowels;
2 |
3 |
4 | import android.annotation.SuppressLint;
5 | import android.app.Activity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.Toast;
12 |
13 | import java.io.FileOutputStream;
14 | public class MainActivity extends Activity implements OnClickListener
15 | {
16 | EditText content;
17 | Button count;
18 | String file_name;
19 |
20 | String strContents;
21 |
22 | @SuppressLint("MissingInflatedId")
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | content=(EditText)findViewById(R.id.editText1);
28 | count=(Button)findViewById(R.id.button1);
29 | count.setOnClickListener(this);
30 | }
31 |
32 | @SuppressLint("WrongConstant")
33 | @Override
34 | public void onClick(View v)
35 | {
36 | if(v.getId()==R.id.button1)
37 | {
38 | FileOutputStream fos;
39 | try {
40 | strContents = content.getText().toString();
41 |
42 | } catch (Exception e) {}
43 | }
44 | if(v.getId()==R.id.button1) {
45 | int count = 0;
46 | for (int i = 0; i < strContents.length(); i++) {
47 |
48 | switch (strContents.charAt(i)) {
49 | case 'a':
50 | case 'e':
51 | case 'i':
52 | case 'o':
53 | case 'u':
54 | case 'A':
55 | case 'E':
56 | case 'I':
57 | case 'O':
58 | case 'U':
59 | count++;
60 | break;
61 | }
62 | }
63 | Toast.makeText(getApplicationContext(), "Total Vovels Are : " + count, Toast.LENGTH_LONG).show();
64 | }
65 | }}
66 |
--------------------------------------------------------------------------------
/Change Font Size and Color/MainActivity.java.java:
--------------------------------------------------------------------------------
1 | package com.example.application1;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 | int ch=1;
13 | float font=30;
14 | // private Bundle savedInstanceState;
15 |
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | final TextView t= (TextView) findViewById(R.id.textview);
21 | Button b1= (Button) findViewById(R.id.button3);
22 | b1.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View v) {
25 | t.setTextSize(font);
26 | font = font + 5;
27 | if (font == 50)
28 | font = 30;
29 | }
30 | });
31 | Button b2= (Button) findViewById(R.id.button5);
32 | b2.setOnClickListener(new View.OnClickListener() {
33 | @Override
34 | public void onClick(View v) {
35 | switch (ch) {
36 | case 1:
37 | t.setTextColor(Color.RED);
38 | break;
39 | case 2:
40 | t.setTextColor(Color.GREEN);
41 | break;
42 | case 3:
43 | t.setTextColor(Color.BLUE);
44 | break;
45 | case 4:
46 | t.setTextColor(Color.CYAN);
47 | break;
48 | case 5:
49 | t.setTextColor(Color.LTGRAY);
50 | break;
51 | case 6:
52 | t.setTextColor(Color.MAGENTA);
53 | break;
54 | default:
55 | throw new IllegalStateException("Unexpected value: " + ch);
56 | }
57 | ch++;
58 | if (ch == 7)
59 | ch = 1;
60 | }
61 | });
62 | }
63 | }
--------------------------------------------------------------------------------
/Change Font Size and Color/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
25 |
26 |
38 |
39 |
51 |
52 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mobile-Application-Development
2 | # Change Font Size and Color
3 | 
4 | # Arithmetic Calculator
5 | 
6 | # Billing
7 | 
8 | # Count Vowels
9 | 
10 | # Intent
11 | 
12 | # Layouts - Vertical
13 | 
14 | # Layouts - Horizontal
15 | 
16 | # Notification Messages
17 | 
18 | # Database Connectivity
19 |
20 |
21 | # 2D Shapes
22 | 
23 | # Email
24 | 
25 | # Location Based Services
26 | 
27 | # Multithreading
28 | 
29 |
--------------------------------------------------------------------------------
/Billing/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.billing;
2 | import androidx.appcompat.app.AppCompatActivity;
3 |
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.Button;
7 | import android.widget.CheckBox;
8 | import android.widget.EditText;
9 | import android.widget.TextView;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 | Button submit;
13 | CheckBox chips, candies, cookies, cakes;
14 | TextView result;
15 | EditText numChips, numCookies, numCandies, numCakes;
16 | @Override
17 | protected void onCreate(Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 | setContentView(R.layout.activity_main);
20 | result = (TextView) findViewById(R.id.result);
21 | submit = (Button) findViewById(R.id.submit);
22 | chips = (CheckBox) findViewById(R.id.chips);
23 | candies = (CheckBox) findViewById(R.id.candy);
24 | cookies = (CheckBox) findViewById(R.id.cookie);
25 | cakes = (CheckBox) findViewById(R.id.cakes);
26 | numCakes = (EditText) findViewById(R.id.numCakes);
27 | numCandies = (EditText) findViewById(R.id.numCandies);
28 | numChips = (EditText) findViewById(R.id.numChips);
29 | numCookies = (EditText) findViewById(R.id.numCookies);
30 | submit.setOnClickListener(new View.OnClickListener() {
31 | int total = 0;
32 | StringBuilder res = new StringBuilder();
33 | @Override
34 | public void onClick(View view) {
35 | if(chips.isChecked() && numChips.getText().toString() != null){
36 | total += 10 * Integer.parseInt(numChips.getText().toString());
37 | }
38 | if(candies.isChecked() && numCandies.getText().toString() != null){
39 | total += 5 * Integer.parseInt(numCandies.getText().toString());
40 | }
41 | if(cakes.isChecked() && numCakes.getText().toString() != null){
42 | total += 50 * Integer.parseInt(numCakes.getText().toString());
43 | }
44 | if(cookies.isChecked() && numCookies.getText().toString() != null){
45 | total += 10 * Integer.parseInt(numCookies.getText().toString());
46 | }
47 | res.append("Total: "+total+"Rs");
48 | result.setText(res.toString());
49 | }
50 | });
51 | }
52 | }
--------------------------------------------------------------------------------
/2D Shapes/2Ddiagram/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.a2ddiagram;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 |
7 | import android.os.Bundle;
8 | import android.app.Activity;
9 | import android.view.Menu;
10 | import android.content.Context;
11 | import android.graphics.Canvas;
12 | import android.graphics.Color;
13 | import android.graphics.Paint;
14 | import android.graphics.Path;
15 | import android.view.View;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 | DemoView demoview;
19 | Paint paint=new Paint();
20 | Path path = new Path();
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | demoview=new DemoView(this);
25 | setContentView(demoview);
26 | }
27 | private class DemoView extends View{
28 | public DemoView(Context context){
29 |
30 | super(context);
31 | }
32 | protected void onDraw(Canvas canvas){
33 | super.onDraw(canvas);
34 |
35 | paint.setStyle(Paint.Style.FILL);
36 | paint.setColor(Color.WHITE);
37 | canvas.drawPaint(paint);
38 |
39 | paint.setAntiAlias(false);
40 | paint.setColor(Color.RED);
41 | canvas.drawRect(300, 100, 1000, 500, paint);
42 |
43 | paint.setAntiAlias(false);
44 | paint.setColor(Color.BLUE);
45 | drawTriangle(canvas, paint, 300, 300, 400);
46 |
47 | paint.setAntiAlias(false);
48 | paint.setColor(Color.GREEN);
49 | canvas.drawRect(100, 500, 500, 1000, paint);
50 |
51 | paint.setColor(Color.MAGENTA);
52 | canvas.drawCircle(300,750,150,paint);
53 |
54 | paint.setAntiAlias(false);
55 | paint.setColor(Color.YELLOW);
56 | canvas.drawRect(500, 500, 1000, 1000, paint);
57 |
58 | }
59 | public void drawTriangle(Canvas canvas, Paint paint, int x, int y, int width) {
60 | int halfWidth = width / 2;
61 |
62 | path.moveTo(x, y - halfWidth); // Top
63 | path.lineTo(x - halfWidth, y + halfWidth); // Bottom left
64 | path.lineTo(x + halfWidth, y + halfWidth); // Bottom right
65 | path.lineTo(x, y - halfWidth); // Back to Top
66 | path.close();
67 |
68 | canvas.drawPath(path, paint);
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/Multithreading/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.multithreading;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.view.View;
7 | import android.widget.TextView;
8 | public class MainActivity extends Activity {
9 | private TextView tvOutput;
10 | private static final int t1 = 1;
11 | private static final int t2 = 2;
12 | private static final int t3 = 3;
13 | @Override
14 | public void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 | tvOutput = (TextView) findViewById(R.id.textView1);
18 | }
19 | public void fetchData(View v) {
20 | tvOutput.setText("Main thread");
21 | thread1.start();
22 | thread2.start();
23 | thread3.start();
24 | }
25 | Thread thread1 = new Thread(new Runnable() {
26 | @Override
27 | public void run() {
28 | for (int i = 0; i < 5; i++) {
29 | try {
30 | Thread.sleep(1000);
31 | } catch (InterruptedException e) {
32 | e.printStackTrace();
33 | }
34 | handler.sendEmptyMessage(t1);
35 | }
36 | }
37 | });
38 | Thread thread2 = new Thread(new Runnable() {
39 | @Override
40 | public void run() {
41 | for (int i = 0; i < 5; i++) {
42 | try {
43 | Thread.sleep(1000);
44 | } catch (InterruptedException e) {
45 | e.printStackTrace();
46 | }
47 | handler.sendEmptyMessage(t2);
48 | }
49 | }
50 | });
51 | Thread thread3 = new Thread(new Runnable() {
52 | @Override
53 | public void run() {
54 | for (int i = 0; i < 5; i++) {
55 | try {
56 | Thread.sleep(1000);
57 | } catch (InterruptedException e) {
58 | e.printStackTrace();
59 | }
60 | handler.sendEmptyMessage(t3);
61 | }
62 | }
63 | });
64 | Handler handler = new Handler() {
65 | public void handleMessage(android.os.Message msg) {
66 | if(msg.what == t1) {
67 | tvOutput.append("\nIn thread 1");
68 | }
69 | if(msg.what == t2) {
70 | tvOutput.append("\nIn thread 2");
71 | }
72 | if(msg.what == t3) {
73 | tvOutput.append("\nIn thread 3");
74 | }
75 | }
76 | };
77 | }
78 |
--------------------------------------------------------------------------------
/Email/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
25 |
32 |
39 |
46 |
53 |
54 |
59 |
60 |
67 |
68 |
74 |
75 |
--------------------------------------------------------------------------------
/Layouts/Horizontal/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
11 |
12 |
16 |
17 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
57 |
58 |
63 |
64 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/ArithmeticCalculator/activty_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
30 |
31 |
32 |
33 |
38 |
39 |
46 |
47 |
54 |
55 |
62 |
63 |
70 |
71 |
72 |
73 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/Layouts/Vertical/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
23 |
24 |
31 |
32 |
36 |
37 |
43 |
44 |
48 |
49 |
56 |
57 |
61 |
62 |
66 |
67 |
68 |
69 |
70 |
82 |
83 |
--------------------------------------------------------------------------------
/ArithmeticCalculator/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.arithmeticcalculator;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.text.TextUtils;
6 | import android.view.View;
7 | import android.view.View.OnClickListener;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 |
12 | public class MainActivity extends AppCompatActivity implements OnClickListener
13 | {
14 | //Defining the Views
15 | EditText Num1;
16 | EditText Num2;
17 | Button Add;
18 | Button Sub;
19 | Button Mul;
20 | Button Div;
21 | TextView Result;
22 |
23 | @Override
24 | public void onCreate(Bundle savedInstanceState)
25 | {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_main);
28 |
29 | //Referring the Views
30 | Num1 = (EditText) findViewById(R.id.editText1);
31 | Num2 = (EditText) findViewById(R.id.editText2);
32 | Add = (Button) findViewById(R.id.Add);
33 | Sub = (Button) findViewById(R.id.Sub);
34 | Mul = (Button) findViewById(R.id.Mul);
35 | Div = (Button) findViewById(R.id.Div);
36 | Result = (TextView) findViewById(R.id.textView);
37 |
38 | // set a listener
39 | Add.setOnClickListener(this);
40 | Sub.setOnClickListener(this);
41 | Mul.setOnClickListener(this);
42 | Div.setOnClickListener(this);
43 | }
44 |
45 | @Override
46 | public void onClick (View v)
47 | {
48 |
49 | float num1 = 0;
50 | float num2 = 0;
51 | float result = 0;
52 | String oper = "";
53 |
54 | // check if the fields are empty
55 | if (TextUtils.isEmpty(Num1.getText().toString()) || TextUtils.isEmpty(Num2.getText().toString()))
56 | return;
57 |
58 | // read EditText and fill variables with numbers
59 | num1 = Float.parseFloat(Num1.getText().toString());
60 | num2 = Float.parseFloat(Num2.getText().toString());
61 |
62 | // defines the button that has been clicked and performs the corresponding operation
63 | // write operation into oper, we will use it later for output
64 | switch (v.getId())
65 | {
66 | case R.id.Add:
67 | oper = "+";
68 | result = num1 + num2;
69 | break;
70 | case R.id.Sub:
71 | oper = "-";
72 | result = num1 - num2;
73 | break;
74 | case R.id.Mul:
75 | oper = "*";
76 | result = num1 * num2;
77 | break;
78 | case R.id.Div:
79 | oper = "/";
80 | result = num1 / num2;
81 | break;
82 | default:
83 | break;
84 | }
85 | // form the output line
86 | Result.setText(num1 + " " + oper + " " + num2 + " = " + result);
87 | }
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/Database Connectivity/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
28 |
36 |
43 |
51 |
58 |
66 |
74 |
82 |
90 |
98 |
106 |
--------------------------------------------------------------------------------
/Billing/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
17 |
25 |
34 |
42 |
51 |
61 |
71 |
81 |
90 |
100 |
--------------------------------------------------------------------------------
/Location Based Services/GPStrace.java:
--------------------------------------------------------------------------------
1 | package com.example.location1;
2 | import android.annotation.SuppressLint;
3 | import android.app.AlertDialog;
4 | import android.app.Service;
5 | import android.content.Context;
6 | import android.content.DialogInterface;
7 | import android.content.Intent;
8 | import android.location.Location;
9 | import android.location.LocationListener;
10 | import android.location.LocationManager;
11 | import android.os.Bundle;
12 | import android.os.IBinder;
13 | import android.provider.Settings;
14 | public class GPStrace extends Service implements LocationListener{
15 | private final Context context;
16 | boolean isGPSEnabled=false;
17 | boolean canGetLocation=false;
18 | boolean isNetworkEnabled=false;
19 | Location location;
20 | double latitude;
21 | double longtitude;
22 | private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES=10;
23 | private static final long MIN_TIME_BW_UPDATES=1000*60*1;
24 | protected LocationManager locationManager;
25 | public GPStrace(Context context)
26 | {
27 | this.context=context;
28 | getLocation();
29 | }
30 | @SuppressLint("MissingPermission")
31 | public Location getLocation()
32 | {
33 | try{
34 | locationManager=(LocationManager) context.getSystemService(LOCATION_SERVICE);
35 | isGPSEnabled=locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
36 | isNetworkEnabled=locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
37 | if(!isGPSEnabled && !isNetworkEnabled){
38 | }else{
39 | this.canGetLocation=true;
40 | if(isNetworkEnabled){
41 | locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES,MIN_DISTANCE_CHANGE_FOR_UPDATES,this);
42 | }
43 | if(locationManager!=null){
44 | location=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
45 | if(location !=null){
46 | latitude=location.getLatitude();
47 | longtitude=location.getLongitude();
48 | }
49 | }
50 | }
51 | if(isGPSEnabled){
52 | if(location==null){
53 | locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
54 | if(locationManager!=null){
55 | location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
56 | if(location!=null){
57 | latitude=location.getLatitude();
58 | longtitude=location.getLongitude();
59 | }
60 | }
61 | }
62 | }
63 | }
64 | catch(Exception e)
65 | {
66 | e.printStackTrace();
67 | }
68 | return location;
69 | }
70 | public void stopUsingGPS(){
71 | if(locationManager!=null){
72 | locationManager.removeUpdates(GPStrace.this);
73 | }
74 | }
75 | public double getLatitude(){
76 | if(location!=null){
77 | latitude=location.getLatitude();
78 | }
79 | return latitude;
80 | }
81 | public double getLongtiude(){
82 | if(location!=null){
83 | longtitude=location.getLatitude();
84 | }
85 | return longtitude;
86 | }
87 | public boolean canGetLocation(){
88 | return this.canGetLocation;
89 | }
90 | public void showSettingAlert(){
91 | AlertDialog.Builder alertDialog=new AlertDialog.Builder(context);
92 | alertDialog.setTitle("GPS is settings");
93 | alertDialog.setMessage("GPS is not enabled.Do you want to go to setting menu?");
94 | alertDialog.setPositiveButton("settings", new DialogInterface.OnClickListener() {
95 | @Override
96 | public void onClick(DialogInterface dialog,int which){
97 | Intent intent=new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
98 | context.startActivity(intent);
99 | }
100 | });
101 | alertDialog.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
102 | @Override
103 | public void onClick(DialogInterface dialog, int which) {
104 | dialog.cancel();
105 | }
106 | });
107 | alertDialog.show();
108 | }
109 | @Override
110 | public void onLocationChanged(Location location) {
111 | }
112 | @Override
113 | public void onProviderDisabled(String provider) {
114 | }
115 | @Override
116 | public void onProviderEnabled(String provider) {
117 | }
118 | @Override
119 | public void onStatusChanged(String provider, int status, Bundle extras) {
120 | }
121 | @Override
122 | public IBinder onBind(Intent intent) {
123 | return null;
124 | }
125 | }
--------------------------------------------------------------------------------
/Database Connectivity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.databaseconnectivity;
2 |
3 |
4 | import android.app.Activity;
5 | import android.app.AlertDialog.Builder;
6 | import android.content.Context;
7 | import android.database.Cursor;
8 | import android.database.sqlite.SQLiteDatabase;
9 | import android.os.Bundle;
10 | import android.view.View;
11 | import android.view.View.OnClickListener;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 |
15 | public class MainActivity extends Activity implements OnClickListener
16 | {
17 | EditText Rollno,Name,Marks;
18 | Button Insert,Delete,Update,View,ViewAll;
19 | SQLiteDatabase db;
20 | /** Called when the activity is first created. */
21 | @Override
22 | public void onCreate(Bundle savedInstanceState)
23 | {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.activity_main);
26 |
27 | Rollno=(EditText)findViewById(R.id.Rollno);
28 | Name=(EditText)findViewById(R.id.Name);
29 | Marks=(EditText)findViewById(R.id.Marks);
30 | Insert=(Button)findViewById(R.id.Insert);
31 | Delete=(Button)findViewById(R.id.Delete);
32 | Update=(Button)findViewById(R.id.Update);
33 | View=(Button)findViewById(R.id.View);
34 | ViewAll=(Button)findViewById(R.id.ViewAll);
35 |
36 | Insert.setOnClickListener(this);
37 | Delete.setOnClickListener(this);
38 | Update.setOnClickListener(this);
39 | View.setOnClickListener(this);
40 | ViewAll.setOnClickListener(this);
41 |
42 | // Creating database and table
43 | db=openOrCreateDatabase("StudentDB", Context.MODE_PRIVATE, null);
44 | db.execSQL("CREATE TABLE IF NOT EXISTS student(rollno VARCHAR,name VARCHAR,marks VARCHAR);");
45 | }
46 | public void onClick(View view)
47 | {
48 | // Inserting a record to the Student table
49 | if(view==Insert)
50 | {
51 | // Checking for empty fields
52 | if(Rollno.getText().toString().trim().length()==0||
53 | Name.getText().toString().trim().length()==0||
54 | Marks.getText().toString().trim().length()==0)
55 | {
56 | showMessage("Error", "Please enter all values");
57 | return;
58 | }
59 | db.execSQL("INSERT INTO student VALUES('"+Rollno.getText()+"','"+Name.getText()+
60 | "','"+Marks.getText()+"');");
61 | showMessage("Success", "Record added");
62 | clearText();
63 | }
64 | // Deleting a record from the Student table
65 | if(view==Delete)
66 | {
67 | // Checking for empty roll number
68 | if(Rollno.getText().toString().trim().length()==0)
69 | {
70 | showMessage("Error", "Please enter Rollno");
71 | return;
72 | }
73 | Cursor c=db.rawQuery("SELECT * FROM student WHERE rollno='"+Rollno.getText()+"'", null);
74 | if(c.moveToFirst())
75 | {
76 | db.execSQL("DELETE FROM student WHERE rollno='"+Rollno.getText()+"'");
77 | showMessage("Success", "Record Deleted");
78 | }
79 | else
80 | {
81 | showMessage("Error", "Invalid Rollno");
82 | }
83 | clearText();
84 | }
85 | // Updating a record in the Student table
86 | if(view==Update)
87 | {
88 | // Checking for empty roll number
89 | if(Rollno.getText().toString().trim().length()==0)
90 | {
91 | showMessage("Error", "Please enter Rollno");
92 | return;
93 | }
94 | Cursor c=db.rawQuery("SELECT * FROM student WHERE rollno='"+Rollno.getText()+"'", null);
95 | if(c.moveToFirst()) {
96 | db.execSQL("UPDATE student SET name='" + Name.getText() + "',marks='" + Marks.getText() +
97 | "' WHERE rollno='"+Rollno.getText()+"'");
98 | showMessage("Success", "Record Modified");
99 | }
100 | else {
101 | showMessage("Error", "Invalid Rollno");
102 | }
103 | clearText();
104 | }
105 | // Display a record from the Student table
106 | if(view==View)
107 | {
108 | // Checking for empty roll number
109 | if(Rollno.getText().toString().trim().length()==0)
110 | {
111 | showMessage("Error", "Please enter Rollno");
112 | return;
113 | }
114 | Cursor c=db.rawQuery("SELECT * FROM student WHERE rollno='"+Rollno.getText()+"'", null);
115 | if(c.moveToFirst())
116 | {
117 | Name.setText(c.getString(1));
118 | Marks.setText(c.getString(2));
119 | }
120 | else
121 | {
122 | showMessage("Error", "Invalid Rollno");
123 | clearText();
124 | }
125 | }
126 | // Displaying all the records
127 | if(view==ViewAll)
128 | {
129 | Cursor c=db.rawQuery("SELECT * FROM student", null);
130 | if(c.getCount()==0)
131 | {
132 | showMessage("Error", "No records found");
133 | return;
134 | }
135 | StringBuffer buffer=new StringBuffer();
136 | while(c.moveToNext())
137 | {
138 | buffer.append("Rollno: "+c.getString(0)+"\n");
139 | buffer.append("Name: "+c.getString(1)+"\n");
140 | buffer.append("Marks: "+c.getString(2)+"\n\n");
141 | }
142 | showMessage("Student Details", buffer.toString());
143 | }
144 | }
145 | public void showMessage(String title,String message)
146 | {
147 | Builder builder=new Builder(this);
148 | builder.setCancelable(true);
149 | builder.setTitle(title);
150 | builder.setMessage(message);
151 | builder.show();
152 | }
153 | public void clearText()
154 | {
155 | Rollno.setText("");
156 | Name.setText("");
157 | Marks.setText("");
158 | Rollno.requestFocus();
159 | }
160 | }
161 |
--------------------------------------------------------------------------------