What you learn: You will learn how to catch/replace the System Applicatio for example the Maps-Activity.
Difficulty: 1.5 of 5
Description:
- Create a standard application as always
- Search for the Activity you want in the dump of the Android internal XML-files (load it :src: Android - Internal XML dumped)
- As we want to replace the Maps Activity we search for sth. like "Maps" and in /android-system-apks/Maps/AndroidManifest.xml" we find what we want.
Using xml Syntax Highlighting- <?xml version="1.0" encoding="utf-8"?>
- <manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:sharedUserId="com.google.android.core"
- android:signature="com.google"
- package="com.google.android.maps">
- <permission
- android:label="@string/read_perm_label"
- android:name="com.google.android.maps.permission.READ_MY_MAPS"
- android:description="@string/read_perm_desc" />
- ....
- <uses-permission android:name="android.permission.ACCESS_GPS" />
- ....
- <application
- android:theme="@android:style/Theme.Dark"
- android:icon="@drawable/ic_launcher_maps"
- android:taskAffinity="com.google.android.maps">
- <activity
- android:label="@string/maps_label"
- android:name="Maps"
- android:launchMode="singleTop">
- ....
- <!-- THIS IS WHAT WE WANT -->
- <intent-filter android:label="@string/google_maps_label">
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="geo" />
- </intent-filter>
- <!-- UP TO HERE -->
- ....
- </activity>
- ....
- </application>
- </manifest>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4 - Open your own AndroidManifest.xml and register the Activity you want your app to listen to it in the AndroidManifest.xml in the following way:Using xml Syntax Highlighting
- ...
- <activity class=".MyJustCreatedApplication" android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="geo" />
- </intent-filter>
- </activity>
- ...
Parsed in 0.002 seconds, using GeSHi 1.0.8.4 - Run the app once and close it (just that it gets installed on the emulator).
- The next time an Intent with a "geo"-uri scheme is broadcasted our app will get started or at least...
- The system will ask you which one of two available activities you want to use to handle the VIEW-Action on the "geo"-scheme:
- the 1st one is the "Maps" standard system activity
- the 2nd one should be yours - Test this it with another app that executes the following line:
[align=center]Thats it
[/align]
Regards,
plusminus




