Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

How to launch an external mobile application from Dynamics 365 for phones

Posted on by Microsoft Employee

Is it possible to launch another Android (or iOS) application directly from the Dynamics 365 for Phones mobile application?

Background:

  • I'd like to add customizations to Dynamics 365 to be able to launch my mobile app directly from the Dynamics 365 for Phones app.
  • I have an Android mobile application that is registered to handle a custom URL scheme (e.g. appscheme://).
  • The Android intent filters are in place for the application to be launched in response to this scheme. This works as expected from a browser. That is, clicking a link or redirecting using a URL of format 'appscheme://' will successfully launch the mobile application. 

Things I've tried:

  • Adding link elements to a web resource. The behaviour varied depending on the link contents. Both worked from Dynamics 365 in the Android Chrome browser:
    • href="appscheme://start?param1=blah": The Dynamics app crashes with an error in logcat: "Application attempted to call on a destroyed WebView."
    • href="intent://start?param1=blah#Intent;package=com.example.app;scheme=appscheme;end;": nothing appears to happen. There is a logcat message: "Activity: External Activity Launch failed. Error: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=intent://start/?param1=blah }"
  • Using the client-side Xrm.Navigation.openUrl function from Javascript with the custom URL scheme or the intent (called from within a web resource). The Dynamics app either crashes, or an exception stack is reported in logcat.
  • Creating a URL-based ribbon button using the custom URI scheme. Nothing seems to happen when the button is pressed.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to launch an external mobile application from Dynamics 365 for phones

    Thanks for the info, I was suspecting that the behaviour had something to do with displaying content from within a WebView.

    [quote]Normally, the shouldOverrideUrlLoading is used when opening an App URI from within a WebView, please see the related links below[/quote]

    This seems to be the case from the Dynamics app. When attempting to navigate to the external application with an intent URI, there is a Dynamics logcat message:

    CrmWebViewClient, shouldOverrideUrlLoading, 15, "Activity: Launching external activity. URL: intent://start/#Intent;package=com.example.app;scheme=appscheme;launchFlags=268468224;end;

    Which suggests to me that the Dynamics app is providing a handler for the shouldOverrideUrlLoading method, but for whatever reason this handler does not open the external application properly.

    [quote]Could you check and grant any relevant app permissions if there is any and see if that fixes the issue?[/quote]

    I enabled all permissions for the Android Dynamics app and it didn't seem to make any difference so I don't think it's a permissions issue.

    [quote]You could consider looking into the possibilities of hooking your javascript function to the WebView control event, You will have to somehow explore the app and get the control names and binds to events.[/quote]

    At this point, I'm not sure what exactly this entails, but I'll certainly look into it. 

    Additional info:

    I looked more closely at the logcat output when clicking the custom URL link from the Dynamics app (e.g. appscheme://start). It appeared as though the external application gets started in some capacity since there appears to be messages related to starting the app such as the loading of native libraries, etc. However as mentioned before, the Dynamics app then crashes and the external application never launches.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: How to launch an external mobile application from Dynamics 365 for phones

    Hi

    I think Dynamics 365 app displays content within a WebView control. So opening the App URL mentioned above from within a WebView Control of an app is different from the opening is directly from Android browser.

    Normally, the shouldOverrideUrlLoading is used when opening an App URI from within a WebView, please see the related links below

    stackoverflow.com/.../open-android-app-from-webview-inside-another-android-app

    stackoverflow.com/.../9394932

    You could consider looking into the possibilities of hooking your javascript function to the WebView control event, You will have to somehow explore the app and get the control names and binds to events.

    stackoverflow.com/.../how-to-fire-javascript-event-in-android-webview-on-app-resume

    The fact that the Dynamics 365 App crashes or logs message about a destroyed WebView, I think the redirection is not happening and it's trying to loads the app somehow within the dynamics 365 App itself.  In short, when you open the URL using Xrm.Navigation.openUrl, it seems to be trying to open within WebView and that would result in crash or error.

    Could you check and grant any relevant app permissions if there is any and see if that fixes the issue?

    If none of these work, you might consider raising a ticket with MS as well to see if they can provide any guidance.  They might give you details about any undocumented events of the WebView that you could hook into.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans