3. 3
Applications
• Written in Java (it’s possible to write native
code & html / javascript also)
• Good separation (and corresponding
security) from other applications:
– Each application runs in its own process
– Each process has its own separate VM
– Each application is assigned a unique Linux
user ID – by default files of that application
are only visible to that application (can be
explicitly exported)
4. 4
Application Components
• Activities – visual user interface focused
on a single thing a user can do
• Services – no visual interface – they run in
the background
• Broadcast Receivers – receive and react
to broadcast announcements
• Content Providers – allow data exchange
between applications
5. 5
Activities
• Basic component of most applications
• Most applications have several activities
that start each other as needed
• Each is implemented as a subclass of the
base Activity class
6. 6
Activities – The View
• Each activity has a default window to draw
in (although it may prompt for dialogs or
notifications)
• The content of the window is a view or a
group of views (derived from View or
ViewGroup)
• Example of views: buttons, text fields,
scroll bars, menu items, check boxes, etc.
• View(Group) made visible via
Activity.setContentView() method.
7. 7
Services
• Does not have a visual interface
• Runs in the background indefinitely
• Examples
– Network Downloads
– Playing Music
– TCP/UDP Server
• You can bind to a an existing service and
control its operation
8. 8
Broadcast Receivers
• Receive and react to broadcast
announcements
• Extend the class BroadcastReceiver
• Examples of broadcasts:
– Low battery, power connected, shutdown,
timezone changed, etc.
– Other applications can initiate broadcasts
9. 9
Content Providers
• Makes some of the application data
available to other applications
• It’s the only way to transfer data between
applications in Android (no shared files,
shared memory, pipes, etc.)
• Extends the class ContentProvider;
• Other applications use a ContentResolver
object to access the data provided via a
ContentProvider
10. 10
Intents
• An intent is an Intent object with a message content.
• Activities, services and broadcast receivers are started
by intents. ContentProviders are started by
ContentResolvers:
– An activity is started by Context.startActivity(Intent intent) or
Activity.startActivityForResult(Intent intent, int RequestCode)
– A service is started by Context.startService(Intent service)
– An application can initiate a broadcast by using an Intent in any
of Context.sendBroadcast(Intent intent),
Context.sendOrderedBroadcast(), and
Context.sendStickyBroadcast()
11. 11
Shutting down components
• Activities
– Can terminate itself via finish();
– Can terminate other activities it started via finishActivity();
• Services
– Can terminate via stopSelf(); or Context.stopService();
• Content Providers
– Are only active when responding to ContentResolvers
• Broadcast Receivers
– Are only active when responding to broadcasts
12. 12
Android Manifest
• Its main purpose in life is to declare the components to the system:
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >
<application . . . >
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
. . . >
</activity>
. . .
</application>
</manifest>
13. 13
Intent Filters
• Declare Intents handled by the current application (in the
AndroidManifest):
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >
<application . . . >
<activity android:name="com.example.project.FreneticActivity"
android:icon="@drawable/small_pic.png"
android:label="@string/freneticLabel"
. . . >
<intent-filter . . . >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter . . . >
<action android:name="com.example.project.BOUNCE" />
<data android:mimeType="image/jpeg" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
. . .
</application>
</manifest>
Shows in the
Launcher and
is the main
activity to
start
Handles JPEG
images in
some way
14. Accessing Hardware - wifi
• package
• android.net.wifi
• Provides classes to manage Wi-Fi functionality on the device.
• The Wi-Fi APIs provide a means by which applications can communicate with the lower-level wireless stack that
provides Wi-Fi network access. Almost all information from the device supplicant is available, including the
connected network's link speed, IP address, negotiation state, and more, plus information about other networks
that are available. Some other API features include the ability to scan, add, save, terminate and initiate Wi-Fi
connections.
• Some APIs may require the following user permissions:
• ACCESS_WIFI_STATE
• CHANGE_WIFI_STATE
• CHANGE_WIFI_MULTICAST_STATE
• Note: Not all Android-powered devices provide Wi-Fi functionality. If your application uses Wi-Fi, declare so with a
<uses-feature> element in the manifest file:
• <manifest ...>
• <uses-feature android:name="android.hardware.wifi" />
• ...
• </manifest>
15. class use case provided by android
• Classes
• ScanResult Describes information about a detected access point.
• WifiConfiguration A class representing a configured Wi-Fi network, including the security configuration.
• WifiConfiguration.AuthAlgorithm Recognized IEEE 802.11 authentication algorithms.
• WifiConfiguration.GroupCipher Recognized group ciphers.
• WifiConfiguration.KeyMgmt Recognized key management schemes.
• WifiConfiguration.PairwiseCipher Recognized pairwise ciphers for WPA.
• WifiConfiguration.ProtocolRecognized security protocols.
• WifiConfiguration.Status Possible status of a network configuration.
• WifiEnterpriseConfig Enterprise configuration details for Wi-Fi.
• WifiEnterpriseConfig.Eap The Extensible Authentication Protocol method used
• WifiEnterpriseConfig.Phase2 The inner authentication method used
• WifiInfo Describes the state of any Wifi connection that is active or is in the process of being set up.
• WifiManager This class provides the primary API for managing all aspects of Wi-Fi connectivity.
• WifiManager.MulticastLock Allows an application to receive Wifi Multicast packets.
• WifiManager.WifiLock Allows an application to keep the Wi-Fi radio awake.
• WifiManager.WpsCallback Interface for callback invocation on a start WPS action
• WpsInfo A class representing Wi-Fi Protected Setup
16. p2p - Peer 2 Peer
Peer 2 Peer Networking is type of
networking where there is no need
of any centralized server , eachnode
works as both server and client
Each node has particular ID
assigned , by which they can
identify internally , IP number for
example , there is no central dns
for assigning ID , depending on
number of nodes , ID's are assigned
No Central Server is Required for P2p based application
17. Wifi basic vs Wifi Direct
• WIFI - BASIC (central acces point)
• Conventional Wi-Fi networks are typically based on the
presence of controller devices known as wireless access
points.
• All nodes are connect to this AP / Router
• WIFI - Direct (p2p based)
• Wi-Fi Direct essentially embeds a software access point
("Soft AP"), into any device that must support Direct.The
soft AP provides a version of Wi-Fi Protected Setup with
its push-button or PIN-based setup.
18. Encryption
• Encryption is the process of encoding
messages or information in such a way that only
authorized parties can read it. Encryption does
not of itself prevent interception, but denies the
message content to the interceptor
19. keys in Encryption
• As shown in example suppose A send
message Hello (encrypted with key)
• that message in communication channel
will be %$#^^&%$#^**^% random
• Againg on B receiver side after
DeCryption
the message becames hello
• Hence , person who is not
authorised(does not have key) cannot
read the message
20. AES - Advance Encry. Sys.
• AES is based on a design principle known as a substitution-permutation network,
combination of both substitution and permutation, and is fast in both software and
hardware.[10] Unlike its predecessor DES, AES does not use a Feistel network.
AES is a variant of Rijndael which has a fixed block size of 128 bits, and a key size
of 128, 192, or 256 bits. By contrast, the Rijndael specification per se is specified
with block and key sizes that may be any multiple of 32 bits, both with a minimum of
128 and a maximum of 256 bits
• We can say it block sustitution system where 128 , 192 or 256 bits block are
substituted to provide encryption
21. wifi direct app code
• Java code logic
• chatbocactivity - Android Activity class
• custombroadcastreciever - Android Broadcast Reciever
• encryptor - Java Cypher
• mainactivity - Android Activity class
• mycustomservice - Android Service class
Layout Files
• activity_chat_box - the screen where chat occurs
• activity_main - Main home screen of app
22. Layout App
• Android uses various views & views
groups to display user & interact with user
• Our Main use is List View
• Home screen utilisez list view to display
peers
• And chat box screen display messages
24. Citation
• Android Studio 1.0
• JDK 7
• Android SDK version 21
• Gradle built script
• Java for logic coding & defination
• xml for layout defination
• xml for manifest & security permission
• java cypher for encryptor class