Thanks to Gabe Sechan who put me on the right track.
First, I was never directly able to run the app on the device and hook into it via the debugger. Rather, I had to start the App on the device via the Android Studio, then click the link on the email which then hooked into the debugger.
The link in the email looked something like this (it has a built in re-direct to our servers):
https://ourcompany.net/redirect?url=myapp%3A%2F%2FDoStuff/123456
This might have been because the way the Intent was setup. Please don't judge, this was here be I was and I know it is not the recommended way of doing Intents, but because of the existing customer base I am not able to re-factor to better approach, in the AndroidManifest.xml:
<activity
android:name="com.mycompany.StartActivity"
android:configChanges="orientation|keyboardHidden|screenSize|keyboard|navigation"
android:label="StartActivity"
android:launchMode="singleTask"
android:windowSoftInputMode="stateHidden" >
<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="myapp" />
</intent-filter>
</activity>
As you can see it is designed to run as a singleton, so when the Intent is activated, rather than calling onCreate() with the App running from the Debugger, it calls onNewIntent(). I needed to add the code to that overloaded method too:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
processIntentLaunch(); // Code to test or run when Intent is triggered...
}
The processIntentLaunch
code:
private void processIntentLaunch() {
// test if this is from an email
try {
Intent intent = getIntent();
if (intent.getAction() != null) {
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
// SAMPLE: myapp://DoStuff/123456
Uri uri = intent.getData();
String host = uri.getHost();
String uriStr = uri.toString();
// An anonymous dispatch
if (host.equalsIgnoreCase("DoStuff")) {
String token = uriStr.substring(uriStr.indexOf("DoStuff") + "DoStuff".length()+1, uriStr.length());
// Now do stuff with the data. Note query string URI probably better, but again bit by previous design
}
}
}
}
catch (Exception ex) {
// Handle error
}
}
This was probably for the best, so besides the code being in the OnCreate (in case the App is not already running) if the App is running, then it will still work (and I can debug the code).
Hope that helps someone else, someday.