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
such as development toolkits for other programming languages, and can write and contribute their own plug-in modules.
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.
1. Communication Between Activities
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
8. Starting Activity For Result
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.
11. Example 1:
12. Example 2:
13. Notifications in Android
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 applications process is killed, the PendingIntent itself will remain usable from other processes.
17. Media in Android
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