Mobile Systems and Smartphone Security�(MOBISEC 2020)
Prof: Yanick Fratantonio�EURECOM
1
Intro to App Development
This slides deck
2
Android apps in a nutshell
3
Android APIs
4
5
Example of APIs: HTTP request (doc)
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
InputStream in = new � BufferedInputStream(urlConnection.getInputStream());
readStream(in);
} finally {
urlConnection.disconnect();
}
6
Example of APIs: Log message (doc)
Log.i("MYAPP", "Logging a message");
Log.e("MOBISEC", "Test message");
7
Example of APIs: access to GPS/location info (doc)
LocationListener list = new MyLocationListener();
list.requestLocationUpdates(
LocationManager.GPS_PROVIDER, 5000,� 10, locationListener);
class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
Toast.makeText("Location" + loc.getLatitude() +� ", " + loc.getLongitude());
}
}
8
Android Framework APIs
9
Package name
10
Basics on Android apps
11
Four main component types
12
Each of these has its own "life cycle"
13
Activity Life Cycle
14
Service
15
Broadcast Receiver
16
Content Provider
17
Communication between components: Intents (doc)
18
Explicit vs. Implicit Intents
19
Example of Explicit Intent
{
...
Intent i = new Intent(this, SecondActivity.class);
i.setData("Here is some data for act2");
i.putExtra("arg1", "And here some more");
startActivity(i);
...
}
20
Add more data with a "Bundle", a key-value store
Example of Implicit Intent
{
...
String url = "http://www.google.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
...
}
21
Action
Intent Filters
22
Android framework versions / API levels (doc)
23
Android framework versions / API levels
24
Android framework versions / API levels
25
Android framework versions / API levels
26
Enough Theory...
27
Example of Activity
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i("MOBISEC", "Hello world!");
}
}
28
The Manifest file (doc)
29
Manifest: Package Name
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
...
</manifest>
30
No one writes these things manually...
Manifest: List of components
<manifest ...>
<application ...>
<activity android:name=".MainActivity" ...>
</activity>
<activity android:name=".JokeActivity" ...>
</activity>
<service android:name=".MyService" ...>
</service>
</application>
</manifest>
31
Manifest: Intent Filters
<activity android:name=".JokeActivity" ...>
<intent-filter>
<action android:name="android.intent.action.ACTION_VIEW_JOKE" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
32
Manifest: Main Activity
<activity android:name=".MainActivity" ...>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
33
Manifest: Min / target SDK
<manifest ...>
<uses-sdk android:minSdkVersion="23"
android:targetSdkVersion="27" />
</manifest>
34
Manifest: Permissions (doc)
<manifest ...>
<uses-permission android:name="android.permission.SEND_SMS"/>
<!-- other permissions go here -->
</manifest>
35
Android Studio and Android SDK
36
How do you actually develop apps?
37
Key things to learn
38
Important "paths"
39
Website Walkthrough
40