Skip to Content

There is a nice blog on SCN about how to use the portal on device to start native apps from Eyal Nathan The example used in the blog is about iOS and more for standard applications – like the twitter app. As the example shows a nice use case for having a mobile portal site with dynamically created content based on the user profile, let`s make sure that the app launcher feature also works on Android and also enhance the example a little bit.

When you develop your corporate app, you can define how the app can be called from a web page. For this, you have to add an intent filter to AndroidManifest.xml

<intent-filter>
<data android:scheme="name" android:host="host" android:pathPrefix="path" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

The important part here is <data>: this section defines a schema. When the schema is being invoked by the browser, the app will open. Each app can have several intent filters defined, so it is possible to assign the app to different schemes.

Example

Trying this out is very easy. Just create a standard Android app and edit the AndroidManifest.xml.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.tobias.mobile.android.test"
  android:versionCode="1"
  android:versionName="1.0" >
  <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
  <application
    android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
    <activity
      android:name=".MainActivity"
      android:label="@string/title_activity_main" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <intent-filter>
        <data android:scheme="tobiastest" android:host="sap" android:pathPrefix="/tobiashofmann" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>
      <intent-filter>
        <data android:scheme="http" android:host="mycoolsapapp.com" android:pathPrefix="/tobiashofmann" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
      </intent-filter>
    </activity>
  </application>
</manifest>

This adds 3 intent filters to the app. The first one is standard, the second defines that the app is responsible for the schema tobiastest and the third one for a “normal” http link. To call the app from a web page, insert links to the 2 new schemes:

Result

/wp-content/uploads/2012/12/podnativeapp1_162999.jpg

If the user clicks on the 1st link (><a href= “tobiastest://sap/tobiashofmann” />), the app is started directly.

/wp-content/uploads/2012/12/podnativeapp2_163000.jpg

If the user now clicks on the 2nd link (<a href= “http://mycoolsapapp.com/tobiashofmann” >Cool SAP app TobiasHofmann</a>), he gets asked which app to call.

/wp-content/uploads/2012/12/podnativeapp3_163001.jpg

This is because the schema used is HTTP and the browser apps are already registered for this schema.

The 2nd example shows that you have to be carefully in choosing the schema. You should only create one when you own the schema when you plan to make your application public. In case of internal applications, you should be able to use your company name (domain) as a schema name. In the later case you can use the same schema, host and separate apps by the path.

Example

Define in AppA:

<data android:scheme=”tobiastest” android:host=”sap” android:pathPrefix=”/tobiashofmann” />

And in AppB

<data android:scheme=”tobiastest” android:host=”sap” android:pathPrefix=”/helloworld” />

Click a link for:

  • tobiastest://sap/tobiashofmann -> AppA will be called
  • tobiastest://sap/helloworld -> AppB will be called

Conclusion

You can use a web page – ideally portal on device with content delivery defined by roles – to give the users an easy way to start apps. The transition between web and native is transparent: meaning that it is easy to use the SAP Portal as a starting point for mobile workers. After logging in (for instance, to a HR mobile portal) they get a list of apps presented they need to execute the task. If the app is now online or native, the user does not need to know. Instead of going to the home screen of the smartphone and start searching for the right app, the portal does that for him.

When apps are delivered automatically to the users smartphone (via Afaria), users may even be switched over to a native app without even knowing it. For them, the way to access / start the app is the same.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply