What you learn: You will learn how to catch/replace the System Applicatio for example the Maps-Activity.
Designed/Tested with sdk-version: m5-rc15
Difficulty: 1.5 of 5
Questions/Problems: Simply post below...
Description:
<?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>
3. 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:
<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>
4.Run the app once and close it (just that it gets installed on the emulator ).
5.The next time an Intent with a "geo"-uri scheme is broadcasted our app will get started or at least... 6. The system will ask you which one of two available activities you want to use to handle the VIEW-Action on the "geo"-scheme:
1.- the 1st one is the "Maps" standard system activity
2. - the 2nd one should be yours
7. Test this it with another app that executes the following line:
startActivity(new Intent(android.content.Intent.VIEW_ACTION, Uri.parse("geo:49.473367,8.660274")));