Reputation: 43
I've got the following situation with a Phonegap 2.9 Android app: I declared a custom intent so that the app can be opened from a website. From within the app, I call an external site I control with a form. On the page of the external site there's a button that is using the custom intent URL to get back to the app.
This construction works for the iOS version of the app, also using Phonegap.
However, for the Android version the popup of Android is saying it doesn't recognizes the custom URL / intent. When I open my browser and navigate to the same external site and pushes the back button with the custom intent-URL, the app gets started.
After searching hours and hours on stackoverflow and the internet in general, I still can't figure out why it isn't working like expected.
Perhaps good to know is that both the app and the external site are using jQuery Mobile. The external site is opened from the app using
navigator.app.loadUrl('https://site.external/');
The page is on a HTTPS / SSL location, does this makes any difference?
The manifest looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
package="com.test.app" android:versionName="1.0" android:versionCode="1" android:hardwareAccelerated="true">
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:hardwareAccelerated="true"
android:debuggable="true"
android:allowBackup="false">
<activity android:name="AppName" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="customurl" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity
android:name="org.apache.cordova.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter></intent-filter>
</activity>
</application>
</manifest>
The code in the external page is using javascript to prevent possible problems with Google automatic search:
window.location = 'customurl://back/';
The error I receive when pushing the button with the custom intent:
Application Error
The protocol is not supported. (customurl://back/)
So, how do I get the external website which was accessed from the app to start the app again, so the user gets back to the app? The only possibility I can think of after searching for hours and hours is to close the app when the user navigates away to the external site.
Upvotes: 2
Views: 374
Reputation: 46856
I think you might need to set a host in the intent filter also:
<data android:scheme="customurl" />
<data android:host="somewebsite.com" />
Can you check to see if that makes a difference?
Upvotes: 1