7. Android Application Components
2. Intents (link)
In Android, you navigate between Activities through which is
known as an intent
Intents enable different activities from different applications
to work together
used to pass information between applications/Apps
7
8. Android Application Components
3. Service
• Application component that performs long-
running operations in background and does
not provide a User Interface
• For example, a service might handle
network transactions, Or play music, all
from the background
8
9. Android Application Components
• 4. Content Providers
• a bridge between applications to share data
• for example the devices contacts information
• we tend to use these, but not create new ones
9
10. Android Application Components
• 5. Broadcast Receivers
• component that responds to system wide announcements
• For example battery low, screen off, date changed
• It is also possible to initiate broadcasts from within an application
10
11. Activities and AndroidManifest.xml
An Android application can be composed of multiple
Activities …
Each activity should be declared in the file:
AndroidManifest.xml
Add a child element of <application>:
Also we need to Add the permissions in Manifest.xml
<application>
<activity android:name=".MyActivity" />
</application>
11
12. How to add a library to your project
From build.gradle file
dependencies {
compile 'com.jakewharton:butterknife:6.0.0'
}
12
13. Persistent Storage
• In Android, there are 5 common ways to store data:
1. Shared Preferences – private key-value pair storage
2. Internal Storage – private storage per-application
3. External Storage – local shared storage (e.g., on SD card)
4. SQLite Database – private structured data
5. Network Storage – store data on your own server
Dr.NoorZaman
13
14. GitHub
• Git is an open-source “version control system”
• What is the benefits of GitHub
allows developers to easily collaborate, as they can download a new
version of the software, make changes, and upload the newest
revision. Every developer can see these new changes, download
them, and contribute.
• Repository is a location where all the files for a particular project
are stored
Dr.NoorZaman
14
21. Webservices
A Web service: is a service offered by an electronic device to
another electronic device
a software system designed to enable the interaction
between machine-to-machine over a network.
23. RESTAPI
What is REST API?
When a web service use REST Architecture we call it a REST API. REST
stands for Representational State Transfer. It relies on a stateless,
client-server, cacheable communications protocol, and in virtually all
cases, the HTTP protocol is used. REST is an architecture style for
designing networked applications.
HTTP Methods
GET To Retrieve Values from Database
POST To Insert new Values to Database
PUT To Update Existing Values in the Database
DELETE To Delete Values from Database
24. RESTAPI
URL Structure
• The above URL will give all the assignments of the student having id 1.
• The above URL will create a new assignment.
URL Method
https://www.Allhabiy.com/student/assignments/1 GET
https://www.Allhabiy.com/student/createassignment POST
25. Android Volley
Android Volley is an HTTP library that makes networking for Android apps
easier and most importantly, faster.
Why Android Volley?
• Volley simplify the networking task in android. With volley can have
• Easy to use request management
• Efficient network management
• Easily customizable according to our need
26. Android Volley
Sendinga SimpleRequest
Use newRequestQueue
final TextView mTextView = (TextView) findViewById(R.id.text);
...
// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
String url ="http://www.google.com";
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
// Display the first 500 characters of the response string.
mTextView.setText("Response is: "+ response.substring(0,500));
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mTextView.setText("That didn't work!");
}
});
// Add the request to the RequestQueue.
queue.add(stringRequest);