SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Communication Between Activities
Intents

• An intent is an abstract description of an operation to be performed.

• Late runtime binding between the code in different applications is
  performed by the use of Intents.
• Its most significant use is in the launching of activities.
Switching between Activities

• Any Android application will comprise of many activities.
• How do they Interact with one another.


Intent intent = new Intent(CallingActivity.this, NewActivity.class);
startActivity(intent);
Passing Data-Using Intent Extras

• Any Android application will comprise of many activities.
• Data needs to be send from one activity to another.

   Intent intent = new Intent(CallingActivity.this, NewActivity.class);
   Use intent.putExtra(“key", val);
   startActivity(intent);
Bundle

• Bundle is generally used for passing data between Activities. It can hold all
  types of values and can pass them to the new activity.
• You can receive data in another Activity like this:

Bundle extras = intent.getExtras();
String dataReceived = extras.getString(“key");
Shared Preferences

• Provides a way to capture user preferences on the settings of
  a specific application or an activity
• Preferences are typically name value pairs
Example - Shared Preferences
Starting Activity For Result
What is Activity Result?

• Most application consists of multiple activities.
• There comes a need for getting some result form the called
  activity
• Could be the list item selected on any activity etc.
Usage

• Call the StartactivityForResult() from the calling Activity with a
  unique request code.
• Create the overridden method OnActivityResult() in the calling
  Activity.
• Set the result to RESULT_OK with the selection stored in the
  intent.
Example 1:
Example 2:
Notifications in Android
NotificationManager

• To show notifications we use NotificationManager Class
   – NotificationManager notificationManager = (NotificationManager)
     getSystemService(NOTIFICATION_SERVICE);


• We use a PendingIntent to specify the action which should be
  performed once the user select the notification.

• You can Receive the activity via PendingIntent.getActivity()
Notification Extras

• Notification.Builder allows to define actions to the
  notification.

• A PendingIntent itself is simply a reference to a token
  maintained by the system.

• This means that, even if its owning application's process
  is killed, the PendingIntent itself will remain usable from
  other processes.
Notifications
Media in Android
Android Media Player

• MediaPlayer is the easier way, if you just want to play an
  audio file in the background, somewhere in an application
• MediaPlayer class can be used to control playback of
  audio/video files and streams
Usage:

• MediaPlayer mp;
• mp = MediaPlayer.create(this, R.raw.song);
• mp.start();
Video Player-Usage


•   VideoView myVideoView
    =(VideoView)findViewById(R.id.myvideoview);
•   myVideoView.setVideoURI(Uri.parse(SrcPath));
•   myVideoView.setMediaController(new
  MediaController(this));
•   myVideoView.requestFocus();
•   myVideoView.start();
Video Player
•Q & A..?
Android webinar class_3

Weitere ähnliche Inhalte

Andere mochten auch (10)

CBSE Maths activity_class_3_8_part3
CBSE Maths activity_class_3_8_part3CBSE Maths activity_class_3_8_part3
CBSE Maths activity_class_3_8_part3
 
Cbse maths activity class_3_8_part2
Cbse maths activity class_3_8_part2Cbse maths activity class_3_8_part2
Cbse maths activity class_3_8_part2
 
Cbse maths activity class_3 to _8_part1
Cbse maths activity class_3 to _8_part1Cbse maths activity class_3 to _8_part1
Cbse maths activity class_3 to _8_part1
 
Telling time powerpoint
Telling time powerpointTelling time powerpoint
Telling time powerpoint
 
Telling the time
Telling the timeTelling the time
Telling the time
 
Telling time
Telling timeTelling time
Telling time
 
Telling the time ppt
Telling the time pptTelling the time ppt
Telling the time ppt
 
Telling the time, tell the time esl efl
Telling the time, tell the time esl eflTelling the time, tell the time esl efl
Telling the time, tell the time esl efl
 
TIME MANAGEMENT POWERPOINT
TIME MANAGEMENT POWERPOINTTIME MANAGEMENT POWERPOINT
TIME MANAGEMENT POWERPOINT
 
Time management ppt
Time management pptTime management ppt
Time management ppt
 

Ähnlich wie Android webinar class_3

Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database faiz324545
 
Android activity intents
Android activity intentsAndroid activity intents
Android activity intentsperpetrotech
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intentPERKYTORIALS
 
04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)TECOS
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & DatabasesMuhammad Sajid
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdfssusere71a07
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptBirukMarkos
 
Android application development
Android application developmentAndroid application development
Android application developmentMd. Mujahid Islam
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptxMugiiiReee
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfAbdullahMunir32
 
Presentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestatePresentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestateOsahon Gino Ediagbonya
 

Ähnlich wie Android webinar class_3 (20)

unit3.pptx
unit3.pptxunit3.pptx
unit3.pptx
 
Android intents in android application-chapter7
Android intents in android application-chapter7Android intents in android application-chapter7
Android intents in android application-chapter7
 
Data Transfer between activities and Database
Data Transfer between activities and Database Data Transfer between activities and Database
Data Transfer between activities and Database
 
Android activity intents
Android activity intentsAndroid activity intents
Android activity intents
 
B2. activity and intent
B2. activity and intentB2. activity and intent
B2. activity and intent
 
04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)04 programmation mobile - android - (db, receivers, services...)
04 programmation mobile - android - (db, receivers, services...)
 
Data Transfer between Activities & Databases
Data Transfer between Activities & DatabasesData Transfer between Activities & Databases
Data Transfer between Activities & Databases
 
Activity & Shared Preference
Activity & Shared PreferenceActivity & Shared Preference
Activity & Shared Preference
 
Android Activities.pdf
Android Activities.pdfAndroid Activities.pdf
Android Activities.pdf
 
Level 1 & 2
Level 1 & 2Level 1 & 2
Level 1 & 2
 
ANDROID
ANDROIDANDROID
ANDROID
 
Intent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).pptIntent, Service and BroadcastReciver (2).ppt
Intent, Service and BroadcastReciver (2).ppt
 
Intents are Awesome
Intents are AwesomeIntents are Awesome
Intents are Awesome
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android intent
Android intentAndroid intent
Android intent
 
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx11.11.2020 - Unit 5-3  ACTIVITY, MENU AND SQLITE DATABASE.pptx
11.11.2020 - Unit 5-3 ACTIVITY, MENU AND SQLITE DATABASE.pptx
 
Mobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdfMobile Application Development -Lecture 09 & 10.pdf
Mobile Application Development -Lecture 09 & 10.pdf
 
Presentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestatePresentation on Android application life cycle and saved instancestate
Presentation on Android application life cycle and saved instancestate
 
Android - Activity, Services
Android - Activity, ServicesAndroid - Activity, Services
Android - Activity, Services
 
Lab1-android
Lab1-androidLab1-android
Lab1-android
 

Mehr von Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaEdureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaEdureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaEdureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaEdureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
 

Mehr von Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Android webinar class_3

  • 2. Intents • An intent is an abstract description of an operation to be performed. • Late runtime binding between the code in different applications is performed by the use of Intents. • Its most significant use is in the launching of activities.
  • 3. Switching between Activities • Any Android application will comprise of many activities. • How do they Interact with one another. Intent intent = new Intent(CallingActivity.this, NewActivity.class); startActivity(intent);
  • 4. Passing Data-Using Intent Extras • Any Android application will comprise of many activities. • Data needs to be send from one activity to another. Intent intent = new Intent(CallingActivity.this, NewActivity.class); Use intent.putExtra(“key", val); startActivity(intent);
  • 5. Bundle • Bundle is generally used for passing data between Activities. It can hold all types of values and can pass them to the new activity. • You can receive data in another Activity like this: Bundle extras = intent.getExtras(); String dataReceived = extras.getString(“key");
  • 6. Shared Preferences • Provides a way to capture user preferences on the settings of a specific application or an activity • Preferences are typically name value pairs
  • 7. Example - Shared Preferences
  • 9. What is Activity Result? • Most application consists of multiple activities. • There comes a need for getting some result form the called activity • Could be the list item selected on any activity etc.
  • 10. Usage • Call the StartactivityForResult() from the calling Activity with a unique request code. • Create the overridden method OnActivityResult() in the calling Activity. • Set the result to RESULT_OK with the selection stored in the intent.
  • 14. NotificationManager • To show notifications we use NotificationManager Class – NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); • We use a PendingIntent to specify the action which should be performed once the user select the notification. • You can Receive the activity via PendingIntent.getActivity()
  • 15. Notification Extras • Notification.Builder allows to define actions to the notification. • A PendingIntent itself is simply a reference to a token maintained by the system. • This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes.
  • 18. Android Media Player • MediaPlayer is the easier way, if you just want to play an audio file in the background, somewhere in an application • MediaPlayer class can be used to control playback of audio/video files and streams
  • 19. Usage: • MediaPlayer mp; • mp = MediaPlayer.create(this, R.raw.song); • mp.start();
  • 20. Video Player-Usage • VideoView myVideoView =(VideoView)findViewById(R.id.myvideoview); • myVideoView.setVideoURI(Uri.parse(SrcPath)); • myVideoView.setMediaController(new MediaController(this)); • myVideoView.requestFocus(); • myVideoView.start();

Hinweis der Redaktion

  1. Java compilers convert your code from human readable Java source files to something called “bytecode” in the Java world. “Bytecode” is interpreted by a JVM, which operates much like a physical CPU might operate on machine code, to actually execute the compiled code. Performance - Java performance in generally second only to C/C++ in common language performance comparisons. In the Java programming language and environment, a just-in-time (JIT) compiler is a program that turns Java bytecode (a program that contains instructions that must be interpreted) into instructions that can be sent directly to the processor.The just-in-time compiler comes with the virtual machine and is used optionally. It compiles the bytecode into platform-specific executable code that is immediately executed
  2. such as development toolkits for other programming languages, and can write and contribute their own plug-in modules.
  3. A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it. If the creating application later re-retrieves the same kind of PendingIntent (same operation, same Intent action, data, categories, and components, and same flags), it will receive a PendingIntent representing the same token if that is still valid, and can thus call cancel() to remove it.