andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

[TinyTut] - Replacing System Application (i.e. Maps)


 
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials
Author Message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2439
Location: College Park, MD

PostPosted: Fri May 16, 2008 7:51 pm    Post subject: [TinyTut] - Replacing System Application (i.e. Maps) Reply with quote

[TinyTut] - Replacing System Application (like Maps)


What you learn: You will learn how to catch/replace the System Applicatio for example the Maps-Activity.

Idea Designed/Tested with sdk-version: m5-rc15

Difficulty: 1.5 of 5 Smile

Idea Questions/Problems: Simply post below...

Description:
  1. Create a standard application as always
  2. Search for the Activity you want in the dump of the Android internal XML-files (load it Source 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.

    XML:
    <?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:
    XML:
           ...
            <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:
    - the 1st one is the "Maps" standard system activity
    - the 2nd one should be yours
  7. Test this it with another app that executes the following line:
    Java:
    startActivity(new Intent(android.content.Intent.VIEW_ACTION, Uri.parse("geo:49.473367,8.660274")));

Thats it Smile

Regards,
plusminus

_________________
Please remember, that this board is give & take Smile

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cabernet1976
Senior Developer
Senior Developer


Joined: 16 Nov 2007
Posts: 147
Location: China

PostPosted: Mon May 19, 2008 12:22 pm    Post subject: Reply with quote

Hi plusminus,

Very good toturials, I rated it 5 stars.
Thanks.

_________________
EveryAlbum - http://www.anddev.org/viewtopic.php?p=7117#7117
Back to top
View user's profile Send private message Visit poster's website
rmeph
Senior Developer
Senior Developer


Joined: 10 Dec 2007
Posts: 111
Location: India

PostPosted: Sat May 24, 2008 1:15 pm    Post subject: Reply with quote

can we add custom menu item in Maps application?????
Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.