· 8 years ago · Feb 26, 2018, 04:14 PM
1 Practical no 1
2Aim: Design an application for a Simple Calculator
3<?xml version="1.0" encoding="utf-8"?>
4<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
5 xmlns:app="http://schemas.android.com/apk/res-auto"
6 xmlns:tools="http://schemas.android.com/tools"
7 android:layout_width="match_parent"
8 android:layout_height="match_parent"
9 android:background="?android:attr/colorBackground"
10 tools:context="com.example.student.calculator341.MainActivity">
11
12 <EditText
13 android:id="@+id/editText"
14 android:layout_width="match_parent"
15 android:layout_height="wrap_content"
16 android:layout_alignParentLeft="true"
17 android:layout_alignParentStart="true"
18 android:layout_alignParentTop="true"
19 android:layout_marginTop="13dp"
20 android:ems="10"
21 android:hint="Enter a Number"
22 android:inputType="textPersonName"
23 tools:ignore="HardcodedText"
24 tools:layout_editor_absoluteX="83dp"
25 tools:layout_editor_absoluteY="-3dp" />
26
27 <EditText
28 android:id="@+id/editText1"
29 android:layout_width="match_parent"
30 android:layout_height="wrap_content"
31 android:layout_below="@+id/editText"
32 android:layout_centerHorizontal="true"
33 android:layout_marginTop="30dp"
34 android:ems="10"
35 android:hint="Enter a Number"
36 android:inputType="textPersonName"
37 tools:ignore="HardcodedText" />
38
39 <Button
40 android:id="@+id/button"
41 android:layout_width="match_parent"
42 android:layout_height="wrap_content"
43 android:layout_alignParentLeft="true"
44 android:layout_alignParentStart="true"
45 android:layout_below="@+id/textView"
46 android:layout_marginTop="14dp"
47 android:background="?attr/colorControlHighlight"
48 android:onClick="add"
49 android:text="+ ADD +"
50 android:textSize="18sp"
51 tools:ignore="HardcodedText" />
52 <Button
53 android:id="@+id/button2"
54 android:layout_width="match_parent"
55 android:layout_height="wrap_content"
56 android:layout_alignParentLeft="true"
57 android:layout_alignParentStart="true"
58 android:layout_below="@+id/button"
59 android:layout_marginTop="28dp"
60 android:background="?attr/colorControlHighlight"
61 android:onClick="sub"
62 android:text="- SUBTRACT -"
63 android:textSize="18sp"
64 tools:ignore="HardcodedText" />
65<Button
66 android:id="@+id/button4"
67 android:layout_width="match_parent"
68 android:layout_height="wrap_content"
69 android:layout_alignParentLeft="true"
70 android:layout_alignParentStart="true"
71 android:layout_below="@+id/button2"
72 android:layout_marginTop="33dp"
73 android:background="?attr/colorControlHighlight"
74 android:onClick="mul"
75 android:text="* MULIPLY *"
76 android:textSize="18sp"
77 tools:ignore="HardcodedText" />
78<Button
79 android:id="@+id/button3"
80 android:layout_width="match_parent"
81 android:layout_height="wrap_content"
82 android:layout_alignParentLeft="true"
83 android:layout_alignParentStart="true"
84 android:layout_below="@+id/button4"
85 android:layout_marginTop="29dp"
86 android:background="?attr/colorControlHighlight"
87 android:onClick="div"
88 android:text="/ DIVIDE /"
89 android:textSize="18sp"
90 tools:ignore="HardcodedText" /
91 <TextView
92 android:id="@+id/textView"
93 android:layout_width="wrap_content"
94 android:layout_height="wrap_content"
95 android:layout_alignParentLeft="true"
96 android:layout_alignParentStart="true"
97 android:layout_below="@+id/editText1"
98 android:layout_marginTop="19dp"
99 android:textColor="@android:color/background_dark"
100 android:textSize="30sp" />
101
102</RelativeLayout>
103Step 2: MainActivity.java
104package com.example.student.calculator341;
105
106import android.support.v7.app.AppCompatActivity;
107import android.os.Bundle;
108import android.view.View;
109import android.widget.EditText;
110import android.widget.TextView;
111
112public class MainActivity extends AppCompatActivity {
113
114 @Override
115 protected void onCreate(Bundle savedInstanceState) {
116 super.onCreate(savedInstanceState);
117 setContentView(R.layout.activity_main);}
118 public void add(View v)
119 {
120 EditText e1=(EditText)findViewById(R.id.editText);
121 EditText e2=(EditText)findViewById(R.id.editText1);
122 TextView t1=(TextView)findViewById(R.id.textView);
123 int num1=Integer.parseInt(e1.getText().toString());
124 int num2=Integer.parseInt(e2.getText().toString());
125 int add=num1+num2;
126 t1.setText(Integer.toString(add));
127 }
128 public void sub(View v){
129 EditText e1=(EditText)findViewById(R.id.editText);
130 EditText e2=(EditText)findViewById(R.id.editText1);
131 TextView t1=(TextView)findViewById(R.id.textView);
132 int num1=Integer.parseInt(e1.getText().toString());
133 int num2=Integer.parseInt(e2.getText().toString());
134 int add=num1-num2;
135 t1.setText(Integer.toString(add));
136 }
137 public void mul(View v)
138 {
139 EditText e1=(EditText)findViewById(R.id.editText);
140 EditText e2=(EditText)findViewById(R.id.editText1);
141 TextView t1=(TextView)findViewById(R.id.textView);
142 int num1=Integer.parseInt(e1.getText().toString());
143 int num2=Integer.parseInt(e2.getText().toString());
144 int add=num1*num2;
145 t1.setText(Integer.toString(add));
146 }
147 public void div(View v)
148 {
149 EditText e1=(EditText)findViewById(R.id.editText);
150 EditText e2=(EditText)findViewById(R.id.editText1);
151 TextView t1=(TextView)findViewById(R.id.textView);
152 int num1=Integer.parseInt(e1.getText().toString());
153 int num2=Integer.parseInt(e2.getText().toString());
154 float add=num1/num2;
155 t1.setText(Float.toString(add));}
156}
157
158
159
160
161
162
163
164
165
166practical no 2
167
168Aim: Understanding the different layouts and design a Food application with radio buttons.
169<?xml version="1.0" encoding="utf-8"?>
170<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
171 xmlns:app="http://schemas.android.com/apk/res-auto"
172 xmlns:tools="http://schemas.android.com/tools"
173 android:layout_width="match_parent"
174 android:layout_height="match_parent"
175 tools:context="com.example.student.foodapplication341.MainActivity">
176
177
178 <TextView
179 android:id="@+id/textView"
180 android:layout_width="wrap_content"
181 android:layout_height="wrap_content"
182 android:layout_alignParentTop="true"
183 android:layout_centerHorizontal="true"
184 android:layout_marginTop="23dp"
185 android:text="Order Food"
186 android:textColor="@android:color/black"
187 android:textSize="30dp" />
188
189 <RadioGroup
190 android:id="@+id/rg"
191 android:layout_width="match_parent"
192 android:orientation="horizontal"
193 android:layout_height="wrap_content"
194 android:layout_marginTop="21dp"
195 android:layout_below="@+id/textView"
196 android:layout_alignParentRight="true"
197 android:layout_alignParentEnd="true">
198
199 <RadioButton
200 android:id="@+id/r1"
201 android:layout_width="wrap_content"
202 android:layout_height="wrap_content"
203 android:text="Veg "/>
204
205 <RadioButton
206 android:id="@+id/r2"
207 android:layout_width="145dp"
208 android:layout_height="wrap_content"
209 android:text="Non-Veg" />
210
211 </RadioGroup>
212
213 <RadioButton
214 android:id="@+id/radioButton"
215 android:layout_width="wrap_content"
216 android:layout_height="wrap_content"
217 android:layout_marginTop="18dp"
218 android:text="Burger"
219 android:layout_below="@+id/rg"
220 android:layout_alignLeft="@+id/rg"
221 android:layout_alignStart="@+id/rg" />
222
223 <RadioButton
224 android:id="@+id/radioButton2"
225 android:layout_width="123dp"
226 android:layout_height="wrap_content"
227 android:text="Birayni"
228 android:layout_below="@+id/radioButton" />
229
230 <RadioButton
231 android:id="@+id/radioButton3"
232 android:layout_width="wrap_content"
233 android:layout_height="wrap_content"
234 android:text="Pizza"
235 android:layout_below="@+id/radioButton2"
236 android:layout_alignLeft="@+id/radioButton2"
237 android:layout_alignStart="@+id/radioButton2" />
238
239 <RadioButton
240 android:id="@+id/radioButton4"
241 android:layout_width="wrap_content"
242 android:layout_height="wrap_content"
243 android:text="Rice"
244 android:layout_below="@+id/radioButton3"
245 android:layout_alignLeft="@+id/radioButton3"
246 android:layout_alignStart="@+id/radioButton3" />
247
248 <Button
249 android:id="@+id/button"
250 android:layout_width="wrap_content"
251 android:layout_height="wrap_content"
252 android:text="order"
253 android:layout_alignParentBottom="true"
254 android:layout_alignParentRight="true"
255 android:layout_alignParentEnd="true" />
256
257 <TextView
258 android:id="@+id/textView2"
259 android:layout_width="wrap_content"
260 android:layout_height="wrap_content"
261 android:text="--------------------------------------------------------------"
262 android:layout_below="@+id/rg"
263 android:layout_alignParentRight="true"
264 android:layout_alignParentEnd="true" />
265
266
267</RelativeLayout>
268
269Step 2: MainActivity.java
270package com.example.student.foodapplication341;
271
272import android.support.v7.app.AppCompatActivity;
273import android.os.Bundle;
274import android.view.View;
275import android.widget.Button;
276import android.widget.RadioButton;
277import android.widget.RadioGroup;
278import android.widget.Toast;
279
280public class MainActivity extends AppCompatActivity {
281 String s="";
282 @Override
283 protected void onCreate(Bundle savedInstanceState) {
284 super.onCreate(savedInstanceState);
285 setContentView(R.layout.activity_main);
286
287 final RadioGroup rg=(RadioGroup)findViewById(R.id.rg);
288 final RadioButton r1=(RadioButton)findViewById(R.id.radioButton);
289 final RadioButton r2=(RadioButton)findViewById(R.id.radioButton2);
290 final RadioButton r3=(RadioButton)findViewById(R.id.radioButton3);
291 final RadioButton r4=(RadioButton)findViewById(R.id.radioButton4);
292
293
294
295
296 Button b1=(Button)findViewById(R.id.button);
297 b1.setOnClickListener(new View.OnClickListener() {
298 @Override
299 public void onClick(View v) {
300 s=s+(r1.isChecked()?"\n"+r1.getText():"");
301 s=s+(r2.isChecked()?"\n"+r2.getText():"");
302 s=s+(r3.isChecked()?"\n"+r3.getText():"");
303 s=s+(r4.isChecked()?"\n"+r4.getText():"");
304 RadioButton rg1=(RadioButton)findViewById(rg.getCheckedRadioButtonId());
305 Toast.makeText(getBaseContext(),"You have ordered "+
306 rg1.getText()+s,Toast.LENGTH_SHORT).show();
307 }
308 });
309 }
310}
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332Practical No: 03
333
334Aim: Implement the concept of styles and themes and to create own custom style.
335Step 1: Write the following code in Activity_Main.xml file.
336<?xml version="1.0" encoding="utf-8"?>
337<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
338 xmlns:app="http://schemas.android.com/apk/res-auto"
339 xmlns:tools="http://schemas.android.com/tools"
340 android:layout_width="match_parent"
341 android:layout_height="match_parent"
342 android:background="@android:color/background_light"
343 android:gravity="center"
344 android:orientation="vertical"
345 android:weightSum="1"
346 tools:context="com.example.satyam.styleandthemes341.MainActivity">
347
348 <RelativeLayout
349 android:layout_width="match_parent"
350 android:layout_height="match_parent">
351
352 <Button
353 android:id="@+id/button"
354 android:layout_width="180dp"
355 android:layout_height="wrap_content"
356 android:text="Submit"
357 android:layout_alignParentBottom="true"
358 android:layout_centerHorizontal="true"
359 android:layout_marginBottom="40dp" />
360
361 <TextView
362 android:id="@+id/textView"
363 android:layout_width="wrap_content"
364 android:layout_height="wrap_content"
365 android:layout_alignLeft="@+id/button"
366 android:layout_alignParentTop="true"
367 android:layout_alignStart="@+id/button"
368 android:layout_marginTop="16dp"
369 android:text="Student Login"
370 android:textColor="@android:color/background_dark"
371 android:textSize="30dp" />
372
373 <EditText
374 android:id="@+id/editText"
375 android:layout_width="match_parent"
376 android:layout_height="35dp"
377 android:layout_below="@+id/textView"
378 android:layout_centerHorizontal="true"
379 android:layout_marginTop="48dp"
380 android:background="@drawable/bg3"
381 android:ems="10"
382 android:gravity="center"
383 android:hint="Enter your phone number"
384 android:inputType="textPersonName"
385 android:textSize="15dp" />
386
387 <EditText
388 android:id="@+id/editText1"
389 android:layout_width="match_parent"
390 android:layout_height="35dp"
391 android:layout_alignLeft="@+id/editText"
392 android:layout_alignStart="@+id/editText"
393 android:layout_below="@+id/editText"
394 android:layout_marginTop="29dp"
395 android:background="@drawable/bg3"
396 android:ems="10"
397 android:gravity="center"
398 android:hint="Enter your phone number"
399 android:inputType="textPersonName"
400 android:textSize="15dp" />
401
402 <AutoCompleteTextView
403 android:id="@+id/t1"
404 android:layout_width="wrap_content"
405 android:layout_height="wrap_content"
406 android:layout_alignEnd="@+id/editText1"
407 android:layout_alignLeft="@+id/editText1"
408 android:layout_alignRight="@+id/editText1"
409 android:layout_alignStart="@+id/editText1"
410 android:layout_below="@+id/editText1"
411 android:layout_marginTop="28dp"
412 android:hint="Select country" />
413
414 </RelativeLayout>
415
416</LinearLayout>
417
418Step 2: MainActivity.java
419package com.example.student.styleandthemes341;
420
421import android.support.v7.app.AppCompatActivity;
422import android.os.Bundle;
423import android.widget.ArrayAdapter;
424import android.widget.AutoCompleteTextView;
425import android.widget.GridView;
426import android.widget.ListView;
427
428public class MainActivity extends AppCompatActivity {
429
430 @Override
431 protected void onCreate(Bundle savedInstanceState) {
432 super.onCreate(savedInstanceState);
433 setContentView(R.layout.activity_main);
434
435 AutoCompleteTextView t1=(AutoCompleteTextView)findViewById(R.id.t1);
436
437 String country_list[] ={"Bulgaria","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia, The", "Georgia", "Germany","Ghana", "Greece", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau","Guyana", "Haiti", "Honduras", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq"};
438
439 ArrayAdapter<String> ad=new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_dropdown_item_1line,country_list);
440
441 t1.setAdapter(ad);
442 t1.setThreshold(1);
443 }
444}
445
446
447
448
449
450
451
452
453Practical No: 04
454
455Aim: Implement an application for Auto text Complete for different countries.
456Step 1: Write the following code in Activity_Main.xml file.
457<?xml version="1.0" encoding="utf-8"?>
458<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
459 xmlns:app="http://schemas.android.com/apk/res-auto"
460 xmlns:tools="http://schemas.android.com/tools"
461 android:layout_width="match_parent"
462 android:layout_height="match_parent"
463 tools:context="com.examples.student.autotextview341.MainActivity">
464
465
466 <AutoCompleteTextView
467 android:layout_width="match_parent"
468 android:layout_height="wrap_content"
469 android:id="@+id/t1"
470 android:hint="Enter your Country"
471 tools:ignore="HardcodedText" />
472</RelativeLayout>
473
474Step 2: Write the following code in MainActivity.java file.
475
476package com.example.student.autotextview341;
477
478import android.support.v7.app.AppCompatActivity;
479import android.os.Bundle;
480import android.widget.ArrayAdapter;
481import android.widget.AutoCompleteTextView;
482
483public class MainActivity extends AppCompatActivity {
484
485 @Override
486 protected void onCreate(Bundle savedInstanceState) {
487 super.onCreate(savedInstanceState);
488 setContentView(R.layout.activity_main);
489 AutoCompleteTextView t1=(AutoCompleteTextView)findViewById(R.id.t1);
490 String county[]={"Bulgaria","France","Egypt","Hungary","India","Iceland","Haiti","Indonesia"};
491 ArrayAdapter<String> ad=new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_dropdown_item_1line,county);
492 t1.setAdapter(ad);
493 t1.setThreshold(1);
494 }
495}
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521Practical No: 06
522
523Aim: Implement the concept of managing a Lifecycle of an Activity.
524Step 1: Write the following code in Activity_Main.xml file.
525<?xml version="1.0" encoding="utf-8"?>
526<android.support.constraint.ConstraintLayout
527 xmlns:android="http://schemas.android.com/apk/res/android"
528 xmlns:tools="http://schemas.android.com/tools"
529 android:layout_width="match_parent"
530 android:layout_height="match_parent"
531 tools:context="com.example.student.lifecycle341.MainActivity">
532</android.support.constraint.ConstraintLayout>
533
534Step 2: MainActivity.java
535package com.example.student.lifecycle341;
536
537import android.support.v7.app.AppCompatActivity;
538import android.os.Bundle;
539import android.widget.Toast;
540
541public class MainActivity extends AppCompatActivity {
542 String message ="Event being invoked";
543 @Override
544 protected void onCreate(Bundle savedInstanceState) {
545 super.onCreate(savedInstanceState);
546 setContentView(R.layout.activity_main);
547 Toast.makeText(MainActivity.this,message,Toast.LENGTH_LONG).show(); }
548 @Override
549 public void onStart(){
550 super.onStart();
551 Toast.makeText(MainActivity.this,"onStart",Toast.LENGTH_LONG).show();
552 }
553 public void onRestart(){
554 super.onRestart();
555 Toast.makeText(MainActivity.this,"onRestart",Toast.LENGTH_LONG).show();
556 }
557 public void onResume(){
558 super.onResume();
559 Toast.makeText(MainActivity.this,"onResume",Toast.LENGTH_LONG).show();
560 }
561 public void onPause(){
562 super.onPause();
563 Toast.makeText(MainActivity.this,"onPause",Toast.LENGTH_LONG).show();
564 }
565 public void onStop(){
566 super.onStop();
567 Toast.makeText(MainActivity.this,"onStop",Toast.LENGTH_LONG).show();
568 }
569 public void onDestroy(){
570 super.onDestroy();
571 Toast.makeText(MainActivity.this,"onDestroy",Toast.LENGTH_LONG).show();}}
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595Practical No: 08
596
597Aim: Using Fragments, link one activity to the next activity of any application
598Step 1: Write the following code in Activity_Main.xml file.
599<?xml version="1.0" encoding="utf-8"?>
600<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
601 xmlns:app="http://schemas.android.com/apk/res-auto"
602 xmlns:tools="http://schemas.android.com/tools"
603 android:layout_width="match_parent"
604 android:layout_height="match_parent"
605 android:background="?attr/colorControlHighlight"
606 tools:context="com.example.student.fragment341.MainActivity">
607
608 <fragment xmlns:android="http://schemas.android.com/apk/res/android"
609 xmlns:tools="http://schemas.android.com/tools"
610 android:id="@+id/fragment"
611 android:name="com.example.student.fragment341.frg"
612 android:layout_width="match_parent"
613 android:layout_height="match_parent"
614 tools:layout="@layout/activity_main2" />
615</RelativeLayout>
616
617Step 2: Write the following code in Activity_Main2.xml file.
618<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
619 xmlns:tools="http://schemas.android.com/tools"
620 android:layout_width="match_parent"
621 android:layout_height="match_parent"
622 android:background="?attr/colorControlHighlight"
623 tools:context=".frg">
624
625 <TextView
626 android:layout_width="wrap_content"
627 android:layout_height="wrap_content"
628 android:layout_alignParentTop="true"
629 android:layout_centerHorizontal="true"
630 android:layout_marginTop="10dp"
631 android:text="Hello From Fragment"
632 android:textColor="@android:color/black"
633 android:textSize="30sp" />
634</RelativeLayout>
635
636Step 3: Write the following code in MainActivity.java file.
637package com.example.student.fragment341;
638
639import android.support.v7.app.AppCompatActivity;
640import android.os.Bundle;
641
642public class MainActivity extends AppCompatActivity {
643 @Override
644 protected void onCreate(Bundle savedInstanceState) {
645 super.onCreate(savedInstanceState);
646 setContentView(R.layout.activity_main);
647 }
648}
649
650Step 4: Write the following code in frg.java file.
651package com.example.student.fragment341;
652
653import android.support.v4.app.Fragment;
654import android.os.Bundle;
655import android.view.LayoutInflater;
656import android.view.View;
657import android.view.ViewGroup;
658
659public class frg extends Fragment {
660 public frg() {
661 }
662 @Override
663 public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
664 return inflater.inflate(R.layout.activity_main2,container, false);
665 }
666}
667
668
669
670
671
672
673
674
675Practical No: 10
676
677Aim: In an application implement the use of Toggle Button.
678Step 1: Write the following code in Activity_Main.xml file.
679<?xml version="1.0" encoding="utf-8"?>
680<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
681 xmlns:app="http://schemas.android.com/apk/res-auto"
682 xmlns:tools="http://schemas.android.com/tools"
683 android:layout_width="match_parent"
684 android:layout_height="match_parent"
685 tools:context="com.example.student.togglebutton341.MainActivity">
686
687
688 <TextView
689 android:id="@+id/textView"
690 android:layout_width="wrap_content"
691 android:layout_height="wrap_content"
692 android:layout_alignParentLeft="true"
693 android:layout_alignParentStart="true"
694 android:layout_alignParentTop="true"
695 android:layout_marginLeft="19dp"
696 android:layout_marginStart="19dp"
697 android:layout_marginTop="16dp"
698 android:text="Wi-Fi"
699 android:textColor="@android:color/black"
700 android:textSize="30sp"
701 tools:ignore="HardcodedText" />
702
703 <TextView
704 android:id="@+id/textView2"
705 android:layout_width="wrap_content"
706 android:layout_height="wrap_content"
707 android:layout_marginTop="15dp"
708 android:text="Bluetooth"
709 android:textColor="@android:color/black"
710 android:textSize="30sp"
711 android:layout_below="@+id/toggleButton"
712 android:layout_alignLeft="@+id/textView"
713 android:layout_alignStart="@+id/textView"
714 tools:ignore="HardcodedText" />
715
716 <ToggleButton
717 android:id="@+id/toggleButton"
718 android:layout_width="wrap_content"
719 android:layout_height="wrap_content"
720 android:layout_alignParentEnd="true"
721 android:layout_alignParentRight="true"
722 android:layout_alignTop="@+id/textView"
723 android:layout_marginEnd="37dp"
724 android:layout_marginRight="37dp"
725 android:text="ToggleButton"
726 tools:ignore="HardcodedText" />
727
728 <ToggleButton
729 android:id="@+id/toggleButton2"
730 android:layout_width="wrap_content"
731 android:layout_height="wrap_content"
732 android:layout_alignLeft="@+id/toggleButton"
733 android:layout_alignStart="@+id/toggleButton"
734 android:layout_alignTop="@+id/textView2"
735 android:text="ToggleButton"
736 tools:ignore="HardcodedText" />
737
738 <Button
739 android:id="@+id/button"
740 android:layout_width="wrap_content"
741 android:layout_height="wrap_content"
742 android:text="Submit"
743 tools:ignore="HardcodedText"
744 android:layout_below="@+id/toggleButton2"
745 android:layout_alignLeft="@+id/toggleButton2"
746 android:layout_alignStart="@+id/toggleButton2"
747 android:layout_marginTop="15dp" />
748</RelativeLayout>
749
750Step 2: Write the following code in MainActivity.java file.
751package com.example.student.togglebutton341;
752
753import android.support.v7.app.AppCompatActivity;
754import android.os.Bundle;
755import android.view.View;
756import android.widget.Button;
757import android.widget.Toast;
758import android.widget.ToggleButton;
759
760public class MainActivity extends AppCompatActivity {
761 private ToggleButton toggleButton1,toggleButton2;
762 private Button buttonSubmit;
763 @Override
764 protected void onCreate(Bundle savedInstanceState) {
765 super.onCreate(savedInstanceState);
766 setContentView(R.layout.activity_main);
767
768 addListenerOnButtonClick();
769 }
770 public void addListenerOnButtonClick() {
771
772 toggleButton1 = (ToggleButton) findViewById(R.id.toggleButton);
773 toggleButton2 = (ToggleButton) findViewById(R.id.toggleButton2);
774 buttonSubmit=(Button)findViewById(R.id.button);
775
776 buttonSubmit.setOnClickListener(new View.OnClickListener() {
777 @Override
778 public void onClick(View view) {
779 StringBuilder result = new StringBuilder();
780 result.append("Wifi is ").append(toggleButton1.getText());
781 result.append("\nBlueTooth is ") .append(toggleButton2.getText());
782 Toast.makeText(getApplicationContext(),result.toString(),Toast.LENGTH_LONG) .show();
783
784 }
785 });
786 }
787}
788
789
790
791
792
793
794
795
796
797
798Practical No: 11
799
800Aim: Design a Menu for any application.
801Step 1: Activity_Main.xml
802<?xml version="1.0" encoding="utf-8"?>
803<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
804 xmlns:app="http://schemas.android.com/apk/res-auto"
805 xmlns:tools="http://schemas.android.com/tools"
806 android:layout_width="match_parent"
807 android:layout_height="match_parent"
808 tools:context="com.example.student.menu341.MainActivity">
809
810</RelativeLayout>
811
812Step 2: Write the following code in MainActivity.java file.
813package com.example.satyam.menu341;
814
815import android.graphics.Color;
816import android.graphics.drawable.ColorDrawable;
817import android.support.v7.app.AppCompatActivity;
818import android.os.Bundle;
819import android.view.Menu;
820import android.view.MenuItem;
821public class MainActivity extends AppCompatActivity {
822 @Override
823 protected void onCreate(Bundle savedInstanceState) {
824 super.onCreate(savedInstanceState);
825 setContentView(R.layout.activity_main);
826 }
827 @Override
828 public boolean onCreateOptionsMenu(Menu menu) {
829 getMenuInflater().inflate(R.menu.menu,menu);
830 return super.onCreateOptionsMenu(menu);
831 }
832 @Override
833 public boolean onOptionsItemSelected(MenuItem item) {
834
835 switch (item.getItemId()){
836
837 case R.id.i1:
838 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED));
839 break;
840 case R.id.i2:
841 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.GREEN));
842 break;
843 case R.id.i3:
844 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
845 break;
846 }
847 return super.onOptionsItemSelected(item);
848 }
849}
850
851Step 3: Create new directory menu and add menu.xml in it.
852Step 4: Write the following code in menu.xml file.
853<?xml version="1.0" encoding="utf-8"?>
854<menu xmlns:app="http://schemas.android.com/apk/res-auto"
855 xmlns:android="http://schemas.android.com/apk/res/android">
856
857 <item android:title="red"
858 android:id="@+id/i1"/>
859 <item android:title="green"
860 android:id="@+id/i2"/>
861 <item android:title="black"
862 android:id="@+id/i3"/>
863</menu>
864
865
866
867
868
869
870
871
872
873
874Practical No: 14
875
876Aim: With the help of Rating Bar, implement a PUSH notification.
877Step 1: Activity_Main.xml
878
879<?xml version="1.0" encoding="utf-8"?>
880<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
881 xmlns:app="http://schemas.android.com/apk/res-auto"
882 xmlns:tools="http://schemas.android.com/tools"
883 android:layout_width="match_parent"
884 android:layout_height="match_parent"
885 tools:context="com.example.student.ratingbarnotification.MainActivity">
886
887 <Button
888 android:onClick="Sub"
889 android:layout_width="wrap_content"
890 android:layout_height="wrap_content"
891 android:text="Submit"
892 android:layout_alignParentBottom="true"
893 android:layout_centerHorizontal="true"
894 android:layout_marginBottom="132dp"
895 tools:ignore="HardcodedText" />
896
897 <TextView
898 android:id="@+id/textView"
899 android:layout_width="wrap_content"
900 android:layout_height="wrap_content"
901 android:textSize="30dp"
902 android:text="Rate Our Service"
903 android:layout_alignParentTop="true"
904 android:layout_centerHorizontal="true"
905 android:layout_marginTop="67dp"
906 tools:ignore="HardcodedText,SpUsage" />
907
908 <RatingBar
909 android:id="@+id/R1"
910 android:layout_width="wrap_content"
911 android:layout_height="wrap_content"
912 android:layout_alignParentTop="true"
913 android:layout_centerHorizontal="true"
914 android:layout_marginTop="133dp" />
915
916</RelativeLayout>
917
918Step 2: MainActivity.java
919
920package com.example.student.ratings341;
921
922import android.app.Notification;
923import android.app.NotificationManager;
924import android.app.PendingIntent;
925import android.content.Intent;
926import android.graphics.Color;
927import android.support.v7.app.AppCompatActivity;
928import android.os.Bundle;
929import android.view.View;
930import android.widget.RatingBar;
931
932public class MainActivity extends AppCompatActivity {
933 private RatingBar R1;
934 @Override
935 protected void onCreate(Bundle savedInstanceState) {
936 super.onCreate(savedInstanceState);
937 setContentView(R.layout.activity_main);
938 R1=(RatingBar) findViewById(R.id.R1);
939 }
940 public void Sub (View view){
941 String fb = String.valueOf(R1.getRating());
942 noti(fb);
943 }
944 void noti (String s){
945 PendingIntent pi = PendingIntent.getActivities(MainActivity.this,0, new Intent[]{new Intent()},0);
946 Notification n1= null;
947 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
948 n1 = new Notification.Builder(this)
949 .setContentTitle("Your Review : ")
950 .setContentText(s)
951 .setTicker("Welcome")
952 .setColor(Color.YELLOW)
953 .setSmallIcon(R.mipmap.ic_launcher)
954 .setContentIntent(pi)
955 .getNotification();
956 }
957 n1.flags=Notification.FLAG_AUTO_CANCEL;
958
959 NotificationManager nm=(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
960 nm.notify(0,n1);
961 }
962}
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989Practical No: 16
990
991Aim: With the help of a Spinner create an Image changer application.
992Step 1: Write the following code in Activity_Main.xml file.
993<?xml version="1.0" encoding="utf-8"?>
994<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
995 xmlns:app="http://schemas.android.com/apk/res-auto"
996 xmlns:tools="http://schemas.android.com/tools"
997 android:layout_width="match_parent"
998 android:layout_height="match_parent"
999 tools:context="com.example.student.imagechanger.MainActivity">
1000
1001
1002 <Spinner
1003 android:id="@+id/s1"
1004 android:layout_width="match_parent"
1005 android:layout_height="wrap_content"
1006 android:layout_marginTop="32dp"
1007 android:layout_alignParentTop="true"
1008 android:layout_alignParentLeft="true"
1009 android:layout_alignParentStart="true"
1010 android:entries="@array/dropValue"/>
1011
1012 <ImageView
1013 android:id="@+id/imageView"
1014 android:layout_width="wrap_content"
1015 android:layout_height="wrap_content"
1016 android:layout_below="@+id/s1"
1017 android:layout_centerHorizontal="true"
1018 android:layout_centerVertical="true"
1019 android:layout_marginTop="21dp"
1020 app:srcCompat="@drawable/earth"
1021 tools:ignore="ContentDescription" />
1022
1023</RelativeLayout>
1024
1025Step 2: Put Images in res>drawable directory.
1026Step 3: Write the following code in MainActivity.java file.
1027package com.example.student.imagechanger341;
1028
1029import android.support.v7.app.AppCompatActivity;
1030import android.os.Bundle;
1031import android.view.View;
1032import android.widget.AdapterView;
1033import android.widget.ImageView;
1034import android.widget.Spinner;
1035
1036public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener{
1037 Spinner s1;
1038 ImageView imageView;
1039 @Override
1040 protected void onCreate(Bundle savedInstanceState) {
1041 super.onCreate(savedInstanceState);
1042 setContentView(R.layout.activity_main);
1043
1044 s1=(Spinner)findViewById(R.id.s1);
1045 imageView=(ImageView)findViewById(R.id.imageView);
1046 s1.setOnItemSelectedListener(this);
1047 }
1048 @Override
1049 public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
1050 switch (position) {
1051 case 0:
1052 imageView.setImageResource(R.drawable.earth);
1053 break;
1054 case 1:
1055 imageView.setImageResource(R.drawable.jupiter);
1056 break;
1057 case 2:
1058 imageView.setImageResource(R.drawable.mars);
1059 break;
1060 case 3:
1061 imageView.setImageResource(R.drawable.mercury);
1062 break;
1063 case 4:
1064 imageView.setImageResource(R.drawable.neptune);
1065 break;
1066 case 5:
1067 imageView.setImageResource(R.drawable.saturn);
1068 break;
1069 case 6:
1070 imageView.setImageResource(R.drawable.uranus);
1071 break;
1072 case 7:
1073 imageView.setImageResource(R.drawable.venus);
1074 break;
1075 }
1076 }
1077
1078 @Override
1079 public void onNothingSelected(AdapterView<?> adapterView) {
1080 }
1081}
1082Step 4: Write the following code in String.xml file.
1083<resources>
1084 <string name="app_name">ImageChanger</string>
1085 <string-array name="dropValue">
1086 <item>Earth</item>
1087 <item>Jupiter</item>
1088 <item>Mars</item>
1089 <item>Mercury</item>
1090 <item>Neptune</item>
1091 <item>Saturn</item>
1092 <item>Uranus</item>
1093 <item>Venus</item>
1094 </string-array>
1095
1096</resources>
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107Practical No: 18
1108
1109Aim: Implement Time Picker and Date Picker.
1110Step 1: in Activity_Main.xml
1111<?xml version="1.0" encoding="utf-8"?>
1112<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1113 xmlns:app="http://schemas.android.com/apk/res-auto"
1114 xmlns:tools="http://schemas.android.com/tools"
1115 android:layout_width="match_parent"
1116 android:layout_height="match_parent"
1117 tools:context="com.example.student.timepicker341.MainActivity">
1118
1119 <ScrollView
1120 android:layout_width="match_parent"
1121 android:layout_height="match_parent">
1122
1123 <RelativeLayout
1124 android:layout_width="match_parent"
1125 android:layout_height="match_parent"
1126 android:orientation="vertical">
1127
1128 <DatePicker
1129 android:id="@+id/dp"
1130 android:layout_width="wrap_content"
1131 android:layout_height="wrap_content"
1132 android:layout_alignParentTop="true"
1133 android:layout_centerHorizontal="true" />
1134
1135 <TextView
1136 android:id="@+id/date"
1137 android:layout_width="wrap_content"
1138 android:layout_height="wrap_content"
1139 android:layout_alignLeft="@+id/dp"
1140 android:layout_alignStart="@+id/dp"
1141 android:layout_alignTop="@+id/dp"
1142 android:layout_below="@+id/dp"
1143 android:layout_marginTop="413dp"
1144 android:text="Date is :"
1145 android:textSize="24sp"
1146 android:textStyle="bold" />
1147
1148 <TimePicker
1149 android:id="@+id/tp"
1150 android:layout_width="wrap_content"
1151 android:layout_height="wrap_content"
1152 android:background="@android:color/transparent"
1153 android:padding="20dp"
1154 android:timePickerMode="spinner"
1155 tools:ignore="UnusedAttribute"
1156 android:layout_marginTop="15dp"
1157 android:layout_below="@+id/date"
1158 android:layout_centerHorizontal="true" />
1159
1160 <TextView
1161 android:id="@+id/time"
1162 android:layout_width="wrap_content"
1163 android:layout_height="wrap_content"
1164 android:layout_alignLeft="@+id/dp"
1165 android:layout_alignStart="@+id/dp"
1166 android:layout_below="@+id/tp"
1167 android:text="Time is :"
1168 android:textSize="24sp"
1169 android:textStyle="bold" />
1170
1171 </RelativeLayout>
1172 </ScrollView>
1173
1174</RelativeLayout>
1175
1176Step 2: Write the following code in MainActivity.java file.
1177package com.example.student.timepicker341;
1178
1179import android.os.Build;
1180import android.support.annotation.RequiresApi;
1181import android.support.v7.app.AppCompatActivity;
1182import android.os.Bundle;
1183import android.widget.DatePicker;
1184import android.widget.TextView;
1185import android.widget.TimePicker;
1186import android.widget.Toast;
1187
1188
1189public class MainActivity extends AppCompatActivity {
1190
1191 TextView time,date;
1192 TimePicker tp;
1193 DatePicker dp;
1194
1195
1196 @RequiresApi(api = Build.VERSION_CODES.O)
1197 @Override
1198 protected void onCreate(Bundle savedInstanceState) {
1199 super.onCreate(savedInstanceState);
1200 setContentView(R.layout.activity_main);
1201 time=(TextView)findViewById(R.id.time);
1202 tp = (TimePicker) findViewById(R.id.tp);
1203 date=(TextView)findViewById(R.id.date);
1204 dp =(DatePicker)findViewById(R.id.dp);
1205
1206 tp.setIs24HourView(false);
1207 tp.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener(){
1208 @Override
1209 public void onTimeChanged(TimePicker view,int hourOfDay,int minute){
1210 Toast.makeText(getApplicationContext(),hourOfDay + " : " + minute,Toast.LENGTH_SHORT).show();
1211 time.setText("Time is :: " + hourOfDay + " : " + minute);
1212 }
1213 });
1214
1215 dp.setOnDateChangedListener(new DatePicker.OnDateChangedListener() {
1216 @Override
1217 public void onDateChanged(DatePicker view,int DayOfMonth,int Month,int Year) {
1218 Toast.makeText(getApplicationContext(), DayOfMonth + "/" + Month + "/" + Year, Toast.LENGTH_LONG).show();
1219 date.setText("Date is :: " + DayOfMonth + "/" + Month + "/" + Year);
1220 }
1221 });
1222 }
1223}
1224
1225
1226
1227
1228
1229
1230
1231
1232Practical No: 22
1233
1234Aim: Design a simple to-do list application using SQLite to Insert , Update and delete the tasks of the list.
1235Step 1: Activity_Main.xml
1236<?xml version="1.0" encoding="utf-8"?>
1237<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1238 xmlns:app="http://schemas.android.com/apk/res-auto"
1239 xmlns:tools="http://schemas.android.com/tools"
1240 android:layout_width="match_parent"
1241 android:layout_height="match_parent"
1242 tools:context="com.example.student.sqliteapplication.MainActivity">
1243 <EditText
1244 android:id="@+id/editText"
1245 android:layout_width="wrap_content"
1246 android:layout_height="wrap_content"
1247 android:layout_alignParentEnd="true"
1248 android:layout_alignParentLeft="true"
1249 android:layout_alignParentRight="true"
1250 android:layout_alignParentStart="true"
1251 android:layout_alignParentTop="true"
1252 android:layout_marginTop="32dp"
1253 android:ems="10"
1254 android:hint="Enter Task No. to Update or Delete"
1255 android:inputType="textPersonName" />
1256 <EditText
1257 android:id="@+id/editText2"
1258 android:layout_width="wrap_content"
1259 android:layout_height="wrap_content"
1260 android:layout_alignParentEnd="true"
1261 android:layout_alignParentLeft="true"
1262 android:layout_alignParentRight="true"
1263 android:layout_alignParentStart="true"
1264 android:layout_below="@+id/editText"
1265 android:ems="10"
1266 android:hint="Enter Task To Insert or Update"
1267 android:inputType="textPersonName" />
1268 <Button
1269 android:id="@+id/button"
1270 android:layout_width="wrap_content"
1271 android:layout_height="wrap_content"
1272 android:layout_alignParentLeft="true"
1273 android:layout_alignParentStart="true"
1274 android:layout_below="@+id/editText2"
1275 android:layout_marginLeft="11dp"
1276 android:layout_marginStart="11dp"
1277 android:layout_marginTop="14dp"
1278 android:onClick="buttonAction"
1279 android:text="Add Task" />
1280 <Button
1281 android:id="@+id/button2"
1282 android:layout_width="wrap_content"
1283 android:layout_height="wrap_content"
1284 android:onClick="buttonAction"
1285 android:text="Update"
1286 android:layout_alignBaseline="@+id/button"
1287 android:layout_alignBottom="@+id/button"
1288 android:layout_centerHorizontal="true" />
1289 <Button
1290 android:id="@+id/button3"
1291 android:layout_width="wrap_content"
1292 android:layout_height="wrap_content"
1293 android:layout_alignBaseline="@+id/button2"
1294 android:layout_alignBottom="@+id/button2"
1295 android:layout_alignParentEnd="true"
1296 android:layout_alignParentRight="true"
1297 android:layout_marginEnd="16dp"
1298 android:layout_marginRight="16dp"
1299 android:onClick="buttonAction"
1300 android:text="Delete" />
1301 <TextView
1302 android:id="@+id/textView"
1303 android:layout_width="wrap_content"
1304 android:layout_height="wrap_content"
1305 android:layout_alignParentBottom="true"
1306 android:layout_alignParentEnd="true"
1307 android:layout_alignParentLeft="true"
1308 android:layout_alignParentRight="true"
1309 android:layout_alignParentStart="true"
1310 android:layout_below="@+id/button" />
1311</RelativeLayout>
1312Step 2: Write the following code in MainActivity.java file.
1313package com.example.student.sqlite341;
1314
1315import android.support.v7.app.AppCompatActivity;
1316import android.os.Bundle;
1317import android.view.View;
1318import android.widget.Button;
1319import android.widget.EditText;
1320import android.widget.TextView;
1321import android.widget.Toast;
1322
1323public class MainActivity extends AppCompatActivity {
1324 EditText id,name;
1325 Button insert,view,update,delete;
1326 TextView text;
1327 dbhandler db;
1328
1329 @Override
1330 protected void onCreate(Bundle savedInstanceState) {
1331 super.onCreate(savedInstanceState);
1332 setContentView(R.layout.activity_main);
1333 id=(EditText)findViewById(R.id.editText);
1334 name=(EditText)findViewById(R.id.editText2);
1335 insert=(Button)findViewById(R.id.button);
1336 update=(Button)findViewById(R.id.button2);
1337 delete=(Button)findViewById(R.id.button3);
1338 db=new dbhandler(getApplicationContext());
1339 text=(TextView)findViewById(R.id.textView);
1340 text.setText(db.getRecord());
1341 }
1342 public void buttonAction(View view){
1343 switch (view.getId()){
1344 case R.id.button:
1345 db.insertRecord(name.getText().toString());
1346 text.setText(db.getRecord());
1347 Toast.makeText(getApplicationContext(),"Record Inserted",Toast.LENGTH_LONG).show();
1348 break;
1349 case R.id.button2:
1350 db.updateRecord(id.getText().toString(),name.getText().toString());
1351 text.setText(db.getRecord());
1352 Toast.makeText(getApplicationContext(),"Record Updated",Toast.LENGTH_LONG).show();
1353 break;
1354 case R.id.button3:
1355 db.deleteRecord(id.getText().toString());
1356 text.setText(db.getRecord());
1357 Toast.makeText(getApplicationContext(),"Record Deleted",Toast.LENGTH_LONG).show();
1358 break;
1359 } }
1360}
1361Step 3: Create a new class dbhandler and write the following code in dbhandler.java file.
1362
1363package com.example.student.sqlitemanipulation341;
1364
1365import android.content.ContentValues;
1366import android.content.Context;
1367import android.database.Cursor;
1368import android.database.sqlite.SQLiteDatabase;
1369import android.database.sqlite.SQLiteOpenHelper;
1370
1371public class dbhandler extends SQLiteOpenHelper {
1372 private static final String DB_NAME="Taskdb";
1373 private static final int DB_VERSION=1;
1374 private static final String TABLE_NAME="record";
1375 private static final String ID_COL="id";
1376 private static final String NAME_COL="name";
1377 public dbhandler(Context context){
1378 super(context,DB_NAME,null,DB_VERSION);
1379 }
1380 @Override
1381 public void onCreate(SQLiteDatabase db) {
1382 String query="CREATE TABLE "+TABLE_NAME+" ("+ID_COL+" INTEGER PRIMARY KEY AUTOINCREMENT,"+NAME_COL+" TEXT)";
1383 db.execSQL(query);
1384 }
1385 @Override
1386 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
1387 db.execSQL("DROP TABLE IF EXIST "+TABLE_NAME);
1388 onCreate(db); }
1389 public void insertRecord(String name){
1390 SQLiteDatabase db=this.getWritableDatabase();
1391 ContentValues values=new ContentValues();
1392 values.put(NAME_COL,name);
1393 db.insert(TABLE_NAME,null,values);
1394 db.close(); }
1395 public String getRecord(){
1396 String query="SELECT * FROM "+TABLE_NAME;
1397 String result="";
1398 SQLiteDatabase db=this.getReadableDatabase();
1399 Cursor cursor=db.rawQuery(query,null);
1400 cursor.moveToFirst();
1401 while (cursor.isAfterLast()==false){ result+="\t\t\t\t\t"+cursor.getString(0)+"\t\t\t\t\t"+cursor.getString(1)+"\n"; cursor.moveToNext(); }
1402 db.close();
1403 return result; }
1404 public void updateRecord(String id,String name){
1405 SQLiteDatabase db=this.getWritableDatabase();
1406 ContentValues values=new ContentValues();
1407 values.put(NAME_COL,name);
1408 db.update(TABLE_NAME,values,"id=?",new String[]{id});
1409 db.close();}
1410 public void deleteRecord(String id){
1411 SQLiteDatabase db=this.getWritableDatabase();
1412 db.delete(TABLE_NAME,"id=?",new String[]{id});
1413 db.close();
1414 }}
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425Practical No: 23
1426
1427Aim: Using SQLite, Insert a student record of a class and search for the record
1428Step 1: Write the following code in Activity_Main.xml file.
1429<?xml version="1.0" encoding="utf-8"?>
1430<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1431 xmlns:app="http://schemas.android.com/apk/res-auto"
1432 xmlns:tools="http://schemas.android.com/tools"
1433 android:layout_width="match_parent"
1434 android:layout_height="match_parent"
1435 tools:context="com.example.student.sqlitestudent341.MainActivity">
1436
1437
1438 <EditText
1439 android:id="@+id/editTextID"
1440 android:layout_width="match_parent"
1441 android:layout_height="wrap_content"
1442 android:layout_alignParentTop="true"
1443 android:layout_centerHorizontal="true"
1444 android:layout_marginTop="17dp"
1445 android:ems="10"
1446 android:hint="ID"
1447 android:inputType="textPersonName" />
1448
1449 <EditText
1450 android:id="@+id/editTextName"
1451 android:layout_width="match_parent"
1452 android:layout_height="wrap_content"
1453 android:layout_below="@+id/editTextID"
1454 android:layout_centerHorizontal="true"
1455 android:layout_marginTop="15dp"
1456 android:ems="10"
1457 android:hint="Name"
1458 android:inputType="textPersonName" />
1459
1460 <EditText
1461 android:id="@+id/editTextMarks"
1462 android:layout_width="match_parent"
1463 android:layout_height="wrap_content"
1464 android:layout_alignEnd="@+id/editTextName"
1465 android:layout_below="@+id/editTextName"
1466 android:layout_marginTop="18dp"
1467 android:ems="10"
1468 android:hint="Marks"
1469 android:inputType="textPersonName" />
1470
1471 <Button
1472 android:id="@+id/button"
1473 android:layout_width="wrap_content"
1474 android:layout_height="wrap_content"
1475 android:text="Insert"
1476 android:layout_below="@+id/editTextMarks"
1477 android:layout_alignParentRight="true"
1478 android:layout_alignParentEnd="true" />
1479
1480 <TextView
1481 android:id="@+id/textView"
1482 android:layout_width="match_parent"
1483 android:layout_height="wrap_content"
1484 android:layout_below="@+id/button"
1485 android:text=" Search"
1486 android:textColor="@android:color/black"
1487 android:textSize="30sp" />
1488
1489 <EditText
1490 android:id="@+id/editTextSearch"
1491 android:layout_width="match_parent"
1492 android:layout_height="wrap_content"
1493 android:ems="10"
1494 android:hint="ID"
1495 android:inputType="textPersonName"
1496 android:layout_below="@+id/textView"
1497 android:layout_alignParentLeft="true"
1498 android:layout_alignParentStart="true" />
1499
1500 <Button
1501 android:id="@+id/button2"
1502 android:layout_width="wrap_content"
1503 android:layout_height="wrap_content"
1504 android:text="Search"
1505 android:layout_below="@+id/editTextSearch"
1506 android:layout_alignParentRight="true"
1507 android:layout_alignParentEnd="true" />
1508</RelativeLayout>
1509
1510Step 2: Write the following code in MainActivity.java file.
1511package com.example.student.sqlitestudent341;
1512
1513import android.content.Context;
1514import android.database.Cursor;
1515import android.database.sqlite.SQLiteDatabase;
1516import android.os.Bundle;
1517import android.support.v7.app.AppCompatActivity;
1518import android.view.View;
1519import android.widget.Button;
1520import android.widget.EditText;
1521import android.widget.Toast;
1522
1523public class MainActivity extends AppCompatActivity {
1524 EditText e1,e2,e3,e4;
1525 Button b1,b2;
1526 SQLiteDatabase sql;
1527
1528 @Override
1529 protected void onCreate(Bundle savedInstanceState) {
1530 super.onCreate(savedInstanceState);
1531 setContentView(R.layout.activity_main);
1532
1533 sql=openOrCreateDatabase("TestDb", Context.MODE_PRIVATE,null);
1534 sql.execSQL("Create Table if not exists students(id primary key,name varchar,marks int);");
1535
1536 e1=(EditText)findViewById(R.id.editTextID);
1537 e2=(EditText)findViewById(R.id.editTextName);
1538 e3=(EditText)findViewById(R.id.editTextMarks);
1539 e4=(EditText)findViewById(R.id.editTextSearch);
1540
1541 b1=(Button)findViewById(R.id.button);
1542 b2=(Button)findViewById(R.id.button2);
1543
1544 b1.setOnClickListener(new View.OnClickListener() {
1545 @Override
1546 public void onClick(View v) {
1547
1548 int id1= Integer.parseInt(e1.getText().toString());
1549 String name1= (e2.getText().toString());
1550 int marks1=Integer.parseInt(e3.getText().toString());
1551 String Query="Insert into students(id,name,marks)values("+id1+",'"+name1+"',"+marks1+");" ;
1552 Toast.makeText(getBaseContext(),"Data Inserted",Toast.LENGTH_LONG).show();
1553 sql.execSQL(Query);
1554 e1.setText("");
1555 e2.setText(""); e3.setText("");
1556 }
1557 });
1558 b2.setOnClickListener(new View.OnClickListener() {
1559 @Override
1560 public void onClick(View v) {
1561 int idn = Integer.parseInt(e4.getText().toString());
1562 String Query = "Select id,name,marks from students where id=" + idn + "";
1563 Cursor C = sql.rawQuery(Query, null);
1564 if (C.moveToFirst()) {
1565 do {
1566 int id = C.getInt(0);
1567
1568 String name = C.getString(1);
1569 int marks = C.getInt(2);
1570 Toast.makeText(getBaseContext(), ("Marks :" + marks + "\nName :" + name), Toast.LENGTH_SHORT).show();
1571
1572
1573 } while (C.moveToNext());
1574 }
1575 } });
1576 }
1577}
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594Practical No: 24
1595
1596Aim:Using SQLite,Internal Storage of data using FileInputStream and FileOutputStream.
1597
1598Step 1: Activity_Main.xml
1599<?xml version="1.0" encoding="utf-8"?>
1600<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1601 xmlns:app="http://schemas.android.com/apk/res-auto"
1602 xmlns:tools="http://schemas.android.com/tools"
1603 android:layout_width="match_parent"
1604 android:layout_height="match_parent"
1605 tools:context="com.example.student.sqlitefilestream341.MainActivity">
1606
1607 <EditText
1608 android:id="@+id/e1"
1609 android:layout_width="match_parent"
1610 android:layout_height="wrap_content"
1611 android:layout_marginTop="11dp"
1612 android:ems="10"
1613 android:hint="Enter File Name"
1614 android:inputType="textPersonName"
1615 android:layout_alignParentTop="true"
1616 android:layout_alignParentLeft="true"
1617 android:layout_alignParentStart="true" />
1618
1619 <EditText
1620 android:id="@+id/e2"
1621 android:layout_width="match_parent"
1622 android:layout_height="wrap_content"
1623 android:layout_alignStart="@+id/e1"
1624 android:layout_below="@+id/e1"
1625 android:layout_marginTop="10dp"
1626 android:ems="10"
1627 android:hint="Enter File Content"
1628 android:inputType="textPersonName" />
1629
1630 <Button
1631 android:id="@+id/button3"
1632 android:layout_width="wrap_content"
1633 android:layout_height="wrap_content"
1634 android:text="Save"
1635 android:onClick="save"
1636 android:layout_below="@+id/e2"
1637 android:layout_alignParentRight="true"
1638 android:layout_alignParentEnd="true" />
1639
1640 <Button
1641 android:id="@+id/button"
1642 android:layout_width="wrap_content"
1643 android:layout_height="wrap_content"
1644 android:layout_alignParentEnd="true"
1645 android:layout_alignParentRight="true"
1646 android:layout_below="@+id/button3"
1647 android:onClick="readdata"
1648 android:text="View" />
1649
1650 <TextView
1651 android:id="@+id/t1"
1652 android:layout_width="wrap_content"
1653 android:layout_height="wrap_content"
1654 android:layout_alignParentBottom="true"
1655 android:layout_alignParentLeft="true"
1656 android:layout_alignParentStart="true"
1657 android:layout_toLeftOf="@+id/button"
1658 android:layout_toStartOf="@+id/button"
1659 android:textAppearance="@android:style/TextAppearance.Material.Large"
1660 android:layout_below="@+id/button3"
1661 tools:targetApi="lollipop" />
1662
1663 <Button
1664 android:id="@+id/button2"
1665 android:layout_width="wrap_content"
1666 android:layout_height="wrap_content"
1667 android:text="delete"
1668 android:onClick="del"
1669 android:layout_below="@+id/button"
1670 android:layout_alignParentRight="true"
1671 android:layout_alignParentEnd="true" />
1672
1673
1674</RelativeLayout>
1675
1676Step 2: Write the following code in MainActivity.java file.
1677
1678package com.example.satyam.sqlitefilestream341;
1679
1680import android.support.v7.app.AppCompatActivity;
1681import android.os.Bundle;
1682import android.view.View;
1683import android.widget.EditText;
1684import android.widget.TextView;
1685import android.widget.Toast;
1686import java.io.BufferedReader;
1687import java.io.File;
1688import java.io.FileOutputStream;
1689import java.io.InputStreamReader;
1690
1691public class MainActivity extends AppCompatActivity {
1692 private EditText e1,e2;
1693 private TextView t1;
1694
1695 @Override
1696 protected void onCreate(Bundle savedInstanceState) {
1697 super.onCreate(savedInstanceState);
1698 setContentView(R.layout.activity_main);
1699
1700 e1 = (EditText) findViewById(R.id.e1);
1701 e2 = (EditText) findViewById(R.id.e2);
1702 t1 = (TextView) findViewById(R.id.t1);
1703
1704 filenames();
1705 }
1706
1707 public void filenames(){
1708 StringBuffer filename=new StringBuffer();
1709 filename.append("Files are : \n--------------------------------------------");
1710 File dirFiles = getFilesDir();
1711 for (String strFile : dirFiles.list())
1712 {
1713 filename.append("\n"+strFile);
1714 }
1715
1716 t1.setText(filename);
1717 }
1718
1719 public void readdata(View v){
1720
1721 StringBuffer stringBuffer = new StringBuffer();
1722 try {
1723 BufferedReader inputReader = new BufferedReader(new InputStreamReader(
1724 openFileInput(e1.getText().toString())));
1725 String inputString;
1726 while ((inputString = inputReader.readLine()) != null) {
1727 stringBuffer.append(inputString + "\n");
1728 }
1729
1730 } catch (Exception e){
1731 Toast.makeText(getApplicationContext(),e.toString(),
1732 Toast.LENGTH_LONG).show();
1733 }
1734 e1.setText("");
1735 Toast.makeText(getApplicationContext(),stringBuffer.toString(),
1736 Toast.LENGTH_LONG).show();
1737 }
1738 public void save(View v){
1739 try {
1740 FileOutputStream fos= openFileOutput(e1.getText().toString(),MODE_PRIVATE);
1741 fos.write(e2.getText().toString().getBytes());
1742 fos.close();
1743 e1.setText("");
1744 e2.setText("");
1745 Toast.makeText(getApplicationContext(),e1.getText() + " saved",
1746 Toast.LENGTH_LONG).show();
1747 filenames();
1748 } catch (Exception e){
1749 Toast.makeText(getApplicationContext(),e.toString(),
1750 Toast.LENGTH_LONG).show();
1751 }
1752 }
1753 public void del(View v){
1754 deleteFile(e1.getText().toString());
1755 filenames();
1756 }
1757}
1758}
1759}
1760
1761
1762
1763
1764
1765
1766
1767
1768Practical No: 25
1769
1770Aim: Display an application for working with Device Camera.
1771Step 1: Write the following code in Activity_Main.xml file.
1772
1773<?xml version="1.0" encoding="utf-8"?>
1774<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1775 xmlns:app="http://schemas.android.com/apk/res-auto"
1776 xmlns:tools="http://schemas.android.com/tools"
1777 android:layout_width="match_parent"
1778 android:layout_height="match_parent"
1779 tools:context="com.example.student.cameraapp.MainActivity">
1780
1781 <Button
1782 android:id="@+id/btnCapture"
1783 android:layout_width="wrap_content"
1784 android:layout_height="wrap_content"
1785 android:text="Capture"
1786 tools:ignore="HardcodedText"
1787 android:layout_marginTop="13dp"
1788 android:layout_alignParentTop="true"
1789 android:layout_centerHorizontal="true" />
1790
1791 <ImageView
1792 android:id="@+id/imgImage"
1793 android:layout_width="wrap_content"
1794 android:layout_height="wrap_content"
1795 android:layout_centerHorizontal="true"
1796 android:layout_centerVertical="true"
1797 app:srcCompat="@mipmap/ic_launcher" />
1798
1799</RelativeLayout>
1800
1801Step 2: Write the following code in MainActivity.java file.
1802package com.example.student.camera341;
1803
1804import android.app.Activity;
1805import android.content.Intent;
1806import android.graphics.Bitmap;
1807import android.support.v7.app.AppCompatActivity;
1808import android.os.Bundle;
1809import android.view.View;
1810import android.widget.Button;
1811import android.widget.ImageView;
1812
1813public class MainActivity extends AppCompatActivity
1814{
1815 Button btnCapture;
1816 ImageView imgImage;
1817
1818 @Override
1819 protected void onCreate(Bundle savedInstanceState)
1820 {
1821 super.onCreate(savedInstanceState);
1822 setContentView(R.layout.activity_main);
1823 btnCapture = (Button)findViewById(R.id.btnCapture);
1824 imgImage = (ImageView)findViewById(R.id.imgImage);
1825 btnCapture.setOnClickListener(new View.OnClickListener()
1826 {
1827 @Override
1828 public void onClick(View view)
1829 {
1830 Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
1831 startActivityForResult(cameraIntent, 9999);
1832 }
1833 });
1834 }
1835 protected void onActivityResult(int requestCode, int resultCode, Intent data)
1836 {
1837 if (requestCode == 9999 && resultCode == Activity.RESULT_OK)
1838 {
1839 Bitmap photo = (Bitmap) data.getExtras().get("data");
1840 imgImage.setImageBitmap(photo);
1841 }
1842 }
1843
1844
1845
1846
1847
1848
1849
1850Practical No:29
1851
1852Aim: Develop an application Phone Call Application.
1853
1854Step 1: Write the following code in Activity_Main.xml file.
1855<?xml version="1.0" encoding="utf-8"?>
1856<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1857 xmlns:app="http://schemas.android.com/apk/res-auto"
1858 xmlns:tools="http://schemas.android.com/tools"
1859 android:layout_width="match_parent"
1860 android:layout_height="match_parent"
1861 tools:context="com.example.student.phone341.MainActivity">
1862
1863 <EditText
1864 android:id="@+id/editText"
1865 android:layout_width="match_parent"
1866 android:layout_height="wrap_content"
1867 android:layout_alignParentLeft="true"
1868 android:layout_alignParentStart="true"
1869 android:layout_alignParentTop="true"
1870 android:layout_marginTop="15dp"
1871 android:ems="10"
1872 android:hint="Enter a Valid Phone Number"
1873 android:inputType="number" />
1874
1875 <Button
1876 android:id="@+id/button"
1877 android:layout_width="wrap_content"
1878 android:layout_height="wrap_content"
1879 android:layout_marginTop="13dp"
1880 android:elevation="0dp"
1881 android:text="Call"
1882 android:layout_below="@+id/editText"
1883 android:layout_centerHorizontal="true" />
1884
1885</RelativeLayout>
1886
1887Step 2: Write the following code in MainActivity.java file.
1888
1889package com.example.student.phone341;
1890
1891import android.content.Intent;
1892import android.net.Uri;
1893import android.os.Bundle;
1894import android.support.v7.app.AppCompatActivity;
1895import android.view.View;
1896import android.widget.Button;
1897import android.widget.EditText;
1898
1899public class MainActivity extends AppCompatActivity {
1900
1901 @Override
1902 protected void onCreate(Bundle savedInstanceState) {
1903 super.onCreate(savedInstanceState);
1904 setContentView(R.layout.activity_main);
1905
1906 final EditText e1=(EditText)findViewById(R.id.editText);
1907 Button b1=(Button)findViewById(R.id.button);
1908 b1.setOnClickListener(new View.OnClickListener() {
1909 @Override
1910 public void onClick(View v) {
1911 String number=e1.getText().toString();
1912 Intent callIntent = new Intent(Intent.ACTION_CALL);
1913 callIntent.setData(Uri.parse("tel:"+number));
1914 startActivity(callIntent);
1915 }
1916 });
1917
1918 }
1919}
1920
1921Step 3: Write the following code in AndroidManifest.xml file.
1922
1923<?xml version="1.0" encoding="utf-8"?>
1924<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1925 package="com.example.student.phone341">
1926 <uses-permission android:name="android.permission.CALL_PHONE" />
1927
1928 <application
1929 android:allowBackup="true"
1930 android:icon="@mipmap/ic_launcher"
1931 android:label="@string/app_name"
1932 android:roundIcon="@mipmap/ic_launcher_round"
1933 android:supportsRtl="true"
1934 android:theme="@style/AppTheme">
1935 <activity android:name=".MainActivity">
1936 <intent-filter>
1937 <action android:name="android.intent.action.MAIN" />
1938
1939 <category android:name="android.intent.category.LAUNCHER" />
1940 </intent-filter>
1941 </activity>
1942 </application>
1943
1944</manifest>
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972Practical No: 19
1973
1974[A] Aim: Using the Web view, Access a website online.
1975Step 1: Write the following code in Activity_Main.xml file.
1976<?xml version="1.0" encoding="utf-8"?>
1977<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
1978 xmlns:app="http://schemas.android.com/apk/res-auto"
1979 xmlns:tools="http://schemas.android.com/tools"
1980 android:layout_width="match_parent"
1981 android:layout_height="match_parent"
1982 tools:context="com.example.student.webview341.MainActivity">
1983 <WebView
1984 android:id="@+id/webView1"
1985 android:layout_width="match_parent"
1986 android:layout_height="match_parent"
1987 android:layout_alignParentBottom="true"
1988 android:layout_alignParentLeft="true"
1989 android:layout_alignParentStart="true"
1990 android:layout_alignParentTop="true" />
1991</RelativeLayout>
1992Step 2: Write the following code in MainActivity.java file.
1993package com.example.student.webview;
1994import android.support.v7.app.AppCompatActivity;
1995import android.os.Bundle;
1996import android.webkit.WebView;
1997public class MainActivity extends AppCompatActivity {
1998 @Override
1999 protected void onCreate(Bundle savedInstanceState) {
2000 super.onCreate(savedInstanceState);
2001 setContentView(R.layout.activity_main);
2002 WebView mywebview = (WebView)findViewById(R.id.webView1);
2003 mywebview.loadUrl("https://www.google.co.in");}}
2004
2005[B] Aim: Using the Web view, Access an HTML page created by the user.
2006Step 1: Write the following code in Activity_Main.xml file.
2007<?xml version="1.0" encoding="utf-8"?>
2008<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2009 xmlns:app="http://schemas.android.com/apk/res-auto"
2010 xmlns:tools="http://schemas.android.com/tools"
2011 android:layout_width="match_parent"
2012 android:layout_height="match_parent"
2013 tools:context="com.example.tarique.webview514.MainActivity">
2014 <WebView
2015 android:id="@+id/webView1"
2016 android:layout_width="match_parent"
2017 android:layout_height="match_parent"
2018 android:layout_alignParentBottom="true"
2019 android:layout_alignParentLeft="true"
2020 android:layout_alignParentStart="true"
2021 android:layout_alignParentTop="true" />
2022</RelativeLayout>
2023
2024Step 2: Write the following code in MainActivity.java file.
2025package com.example.student.webview;
2026import android.support.v7.app.AppCompatActivity;
2027import android.os.Bundle;
2028import android.webkit.WebView;
2029public class MainActivity extends AppCompatActivity {
2030 @Override
2031 protected void onCreate(Bundle savedInstanceState) {
2032 super.onCreate(savedInstanceState);
2033 setContentView(R.layout.activity_main);
2034 WebView mywebview = (WebView)findViewById(R.id.webView1);
2035 mywebview.loadUrl("http://www.google.com");
2036 String data ="<html><body><h1>Hello Tarique</h1></body></html>";
2037 mywebview.loadData(data,"text/html","UTF-8");}}
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049 Practical No.20
2050
2051
2052Step 1: Write the following code in Activity_Main.xml file
2053<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2054 xmlns:tools="http://schemas.android.com/tools"
2055 android:layout_width="match_parent"
2056 android:layout_height="match_parent"
2057 tools:context=".MainActivity" >
2058
2059 <EditText
2060 android:id="@+id/time"
2061 android:layout_width="wrap_content"
2062 android:layout_height="wrap_content"
2063 android:layout_alignParentLeft="true"
2064 android:layout_alignParentTop="true"
2065 android:layout_marginTop="28dp"
2066 android:ems="10"
2067 android:hint="Number of seconds"
2068 android:inputType="numberDecimal" />
2069
2070 <Button
2071 android:id="@+id/button1"
2072 android:layout_width="wrap_content"
2073 android:layout_height="wrap_content"
2074 android:layout_alignRight="@+id/time"
2075 android:layout_below="@+id/time"
2076 android:layout_marginRight="60dp"
2077 android:layout_marginTop="120dp"
2078 android:text="Start" />
2079
2080</RelativeLayout>
2081
2082Step 2: Write the following code in MainActivity.java file.
2083
20841. package com.example.alarmexample;
20852.
20863. import android.app.Activity;
20874. import android.app.AlarmManager;
20885. import android.app.PendingIntent;
20896. import android.content.Intent;
20907. import android.os.Bundle;
20918. import android.view.View;
20929. import android.view.View.OnClickListener;
209310. import android.widget.Button;
209411. import android.widget.EditText;
209512. import android.widget.Toast;
209613.
209714. public class MainActivity extends Activity {
209815. Button b1;
209916.
210017. @Override
210118. protected void onCreate(Bundle savedInstanceState) {
210219. super.onCreate(savedInstanceState);
210320. setContentView(R.layout.activity_main);
210421. b1=(Button) findViewById(R.id.button1);
210522.
210623. b1.setOnClickListener(new OnClickListener() {
210724.
210825. @Override
210926. public void onClick(View v) {
2110 // TODO Auto-generated method stub
2111 startAlert();
2112 }
2113 });
2114
2115} public void startAlert() {
2116 EditText text = (EditText) findViewById(R.id.time);
2117 int i = Integer.parseInt(text.getText().toString());
2118 Intent intent = new Intent(this, MyBroadcastReceiver.class);
2119 PendingIntent pendingIntent = PendingIntent.getBroadcast(
2120 this.getApplicationContext(), 234324243, intent, 0);
2121 AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
2122 alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
2123 + (i * 1000), pendingIntent);
2124 Toast.makeText(this, "Alarm set in " + i + " seconds",Toast.LENGTH_LONG).show();
2125 }
2126
2127}
2128
2129
2130File: MyBroadcastReceiver.java
2131
2132
21331. package com.example.alarmexample;
21342. import android.content.BroadcastReceiver;
21353. import android.content.Context;
21364. import android.content.Intent;
21375. import android.media.MediaPlayer;
21386. import android.widget.Toast;
21397.
21408. public class MyBroadcastReceiver extends BroadcastReceiver {
21419. MediaPlayer mp;
214210. @Override
214311. public void onReceive(Context context, Intent intent) {
214412. mp=MediaPlayer.create(context, R.raw.alrm );
214513. mp.start();
214614. Toast.makeText(context, "Alarm....", Toast.LENGTH_LONG).show();
214715. }
214816. }
2149File: AndroidManifest.xml
2150You need to provide a receiver entry in AndroidManifest.xml file.
21511. <receiver android:name="MyBroadcastReceiver" >
21522. </receiver>
2153Let's see the full code of AndroidManifest.xml file.
21541. <?xml version="1.0" encoding="utf-8"?>
21552. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
21563. package="com.example.alarmexample"
21574. android:versionCode="1"
21585. android:versionName="1.0" >
21596.
21607. <uses-sdk
21618. android:minSdkVersion="8"
21629. android:targetSdkVersion="16" />
216310.
216411. <uses-permission android:name="android.permission.VIBRATE" />
216512.
216613.
216714. <application
216815. android:allowBackup="true"
216916. android:icon="@drawable/ic_launcher"
217017. android:label="@string/app_name"
217118. android:theme="@style/AppTheme" >
217219. <activity
217320. android:name="com.example.alarmexample.MainActivity"
217421. android:label="@string/app_name" >
217522. <intent-filter>
217623. <action android:name="android.intent.action.MAIN" />
217724.
217825. <category android:name="android.intent.category.LAUNCHER" />
217926. </intent-filter>
218027. </activity>
218128.
218229. <receiver android:name="MyBroadcastReceiver" >
218330. </receiver>
218431. </application>
218532.
218633. </manifest>