I'm having trouble starting a background activity using FCM click_action.
My manifesto:
<activity
android:name="com.myoro.MainActivity"
android:theme="#style/AppTheme.NoActionBar"/>
<activity
android:name="com.myoro.ActivityA"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="com.myoro.A" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.myoro.ActivityB"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="com.myoro.B" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
My message settings:
data: {{"type" : "A","id" : "a123","click_action": "com.myoro.A"}}
JAVA:
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (remoteMessage.getData().size() > 0) {
if (remoteMessage.getData().containsKey("click_action")) {
Intent intent = new Intent(remoteMessage.getData().get("click_action"));
intent.putExtra("id", remoteMessage.getData().get("id"));
startActivity(intent);
return;
}
if (remoteMessage.getData().containsKey("data")) {
String data = remoteMessage.getData().get("data");
Gson gson = new Gson();
MyObj myObj = gson.fromJson(data, MyObj.class);
if(myObj.getType().equals("A")) {
Intent intent = new Intent(context, ActivityA.class);
intent.putExtra("id", myObj.getId());
startActivity(intent);
} else {
Intent intent = new Intent(context, ActivityB.class);
intent.putExtra("id", myObj.getId());
startActivity(intent);
}
}
}
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
}
In case I am trying to send this json model and it is always opening the activity main. How can I manipulate the notification click in fourground and background to open the ActivityA and ActivityB and need to pass the id?...
click_action is a parameter that should be used inside a notification message payload, not data.
Try to edit your payload to something like:
}
notification:{
"click_action": "com.myoro.A"
},
data: {
"type" : "A",
"id" : "a123"
}
}
See the FCM HTTP parameters for reference:
https://firebase.google.com/docs/cloud-messaging/http-server-ref
Related
I have an app that receives simple data (text) from other apps through the other app sharing to my app. Part of the manifest looks like this:
<activity
android:name=".presentation.ui.activities.MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
When the activity hasn't been created yet, I share the text data from the other app to my app and handle the intent with action intent.action.Send in the onCreate method. However, I also want to be able to share the text data while the app is in the background. When the app is in the background and I share the text data from the other app, the action is intent.action.MAIN in the onRestart or onResume methods.
This is the handleIntent method
private void handleIntent(){
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
String text = intent.getStringExtra(Intent.EXTRA_TEXT);
// logic
}
}
}
How do I receive the text data from the other app while my app is in the background?
I have figured it out.
I overrode the newIntent method
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
handleIntent(intent);
}
Sending Simple Data to Other Apps
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
Receiving Simple Data from Other Apps
Update Your Manifest
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Handle the Incoming Content
void onCreate (Bundle savedInstanceState) {
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
handleSendText(intent); // Handle text being sent
}
}
}
void handleSendText(Intent intent) {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
if (sharedText != null) {
// Update UI to reflect text being shared
}
}
Hi Here i write it using Firebase Notification,i am used onMessageReceived to get notification,and send it on sendNotification functionality,Here my problem is ,my app is sleep mode,when i click the notification i need to go main activity page,but i got error ,its started from splash screen Here is my code on Firebase Messaging Service
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
String data;
String jsonObject;
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getFrom()); //MyFirebaseMsgService: From: 1055554437945
// Check if message contains a data payload.
data = String.valueOf(remoteMessage.getData());
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
if (remoteMessage.getData().size() > 0) {
jsonObject = remoteMessage.getData().toString();
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getTitle()); ////MyFirebaseMsgService: Message Notification Body: Customer request for service
if (remoteMessage.getNotification().getTitle().equalsIgnoreCase("Service Request")) {
sendNotification(remoteMessage.getNotification().getBody(), remoteMessage.getData().toString());
}
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
/**
* Create and show a simple notification containing the received FCM message.
*
* #param messageBody FCM message body received.
*/
private void sendNotification(String messageBody, String values) {
Log.i("messageBodymageBody", "" + messageBody);
if (isUserLoggedIn()) {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("values", values);
intent.putExtra("identify", "1");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(intent);
PendingIntent contentIntent = stackBuilder
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT
| PendingIntent.FLAG_ONE_SHOT);
startActivity(intent);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.fixmelogo)
.setContentTitle("Service Request")
.setContentText("Customer request for service")
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(contentIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
} else {
Intent intent1 = new Intent(this, LoginActivity.class);
startActivity(intent1);
}
}
public boolean isUserLoggedIn() {
Log.i("bollcheck", "" + UserInformations.getUserInformations(this).getId() + UserInformations.getUserInformations(this).getEmail());
/*if (UserInformations.getUserInformations(this).getId() != null || UserInformations.getUserInformations(this).getEmail() != null
|| UserInformations.getUserInformations(this).getMobile() != null) {*/
return UserInformations.getUserInformations(this).getId().trim().length() > 0;
}}
and also my manifest file
<application
android:name=".App"
android:allowBackup="true"
android:icon="#drawable/fixmelogo"
android:label="#string/app_name"
android:roundIcon="#drawable/fixmelogo"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Activity.SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".FirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".FirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="#drawable/fixmelogo" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color"
android:resource="#color/colorPrimary" />
<activity android:name=".Activity.MainActivity"
android:exported="true"/>
<activity android:name=".Activity.TripActivity" />
</application>
when I click notification need to Main Activity, but it's going from splash Screen page, Sorry for my poor English, I am Beginner of the Android, kindly give some solution
Hi Here my Notification Json from Server
{
"to":"d7XvGt8pD60:APA91bEjEe9IjhjJDmojvRDogMp1xc4sQFT9EcoB8TBvM-rCtkwryFhRVGvHIx1T6CWMoJu3l4UuaXgkgWrFj_Fo1SFhip9C-RXuthO6pfHvJ4GRQOipWtiVjUl9wtO7jfVd-T6jMBpJ",
"notification":{
"body":"Customer request for service",
"title":"Service Request",
"sound":"mySound"
},
"data":{
"CustomerId":"99",
"CustomerName":"Mayil",
"CustomerLastName":"Kannan",
"PhoneNumber":"96788484887",
"PickupLocation":"Ponmeni Muniyaandi koil main road, Chandragandhi Nagar, Ponmeni, Madurai, Tamil Nadu 625016",
"DropLocation":"Ponmeni Muniyaandi koil main road, Chandragandhi Nagar, Ponmeni, Madurai, Tamil Nadu 625016",
"PickupLatitude":"9.92074762937605",
"PickupLongitude":"78.0926296301913",
"DropLatitude":"9.92074762937605",
"DropLongitude":"78.0926296301913"
}
}
they Are sending like this.
I'm having an issue with Firebase notifications. I set up it as the docs but it's not working. Below, you can see my code. Although I think everything is right.
Here's my NotificationsService
public class NotificationsService extends FirebaseMessagingService {
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
String TAG = "Notification";
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
}
// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
}
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
}
}
And the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.usefashion.useapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/Theme.AppCompat.NoActionBar">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".NotificationsService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".InstanceIdService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
It would be great if anyone could help me. I have an InstanceIdService too but its not the part of this question.
Edit 1:
I realized that when I send a notification by console, this message is showed in debug:
E/FirebaseInstanceId: Error resolving target intent service, skipping classname enforcement. Resolved service was: com.taplane.triviaquiz/com.msi.logocore.helpers.thirdparty.firebase.FirebaseServiceListener
What is it?
hers's my fcm services:
=> public class MyFirebaseInstanceIdServices extends FirebaseInstanceIdService {
private static final String TAG = "MyFirebaseIIDService";
#Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
Log.d(TAG, "FireBase token: " + refreshedToken);
Prefs.setFirebaseToken(getApplicationContext(), refreshedToken);
}
}
=> public class MyFirebaseMessagingServices extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMsgService";
#Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "From: " + remoteMessage.getData() + " Message Body");
Map<String, String> notiMessage = remoteMessage.getData();
String type = notiMessage.get("type");
String title = notiMessage.get("title");
String message = notiMessage.get("message");
String orderId = notiMessage.get("order_id");
sendNotification(type, title, message, orderId);
}
//This method is only generating push notification
private void sendNotification(String type, String title, String message, String orderId) {
if (Prefs.getIsLogin(this)) {
Intent intent = null;
if (type.equals("order")) {
intent = new Intent(this, OrderConfirmationActivity.class);
intent.putExtra(Constant.ORDER_ID, orderId);
intent.putExtra("FromNoti", true);
} else {
intent = new Intent(this, HomeActivity.class);
}
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_ONE_SHOT);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_marker);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(bitmap)
.setContentTitle(title)
.setContentText(message)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
}
=> In Manifest file:
<service android:name="com.labagel.fcm.MyFirebaseMessagingServices">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.labagel.fcm.MyFirebaseInstanceIdServices">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
i've tried to sending data between App1 to App2 via Intent in Android
i used this code but i couldn't resolve my problem.
App1 MainActivity :
Intent i2 = new Intent("com.appstore.MainActivity");
i2.setPackage("com.appstore");//the destination packageName
i2.putExtra("Id", "100");
startActivity(i2);
App2 MainActivity :
Bundle data = getIntent().getExtras;
if(data!=null){
String myString = b.getString("Id");
}
Manfiest App2 MainActivity:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
Final code:
App 1 :
Intent intent = new Intent();
intent.setClassName("com.appstore", "com.appstore.MyBroadcastReceiver");
intent.setAction("com.appstore.MyBroadcastReceiver");
intent.putExtra("KeyName","code1id");
sendBroadcast(intent);
App 2:
Reciver:
public class MyBroadcastReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Data Received from External App", Toast.LENGTH_SHORT).show();
}
}
Manifest :
<receiver
android:name=".MyBroadcastReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="first_app_packagename" />
</intent-filter>
</receiver>
MainActivity :
MyBroadcastReceiver mReceiver = new MyBroadcastReceiver();
registerReceiver(mReceiver,
new IntentFilter("first_app_packagename"));
My requirement was to send the "user id" from App1 to App2 and get "username" back to App1.
I needed to launch my app directly without any chooser. I was able to achieve this using implicit intent and startActivityForResult.
App1 > MainActivity.java
private void launchOtherApp() {
Intent sendIntent = new Intent();
//Need to register your intent filter in App2 in manifest file with same action.
sendIntent.setAction("com.example.sender.login"); // <packagename.login>
Bundle bundle = new Bundle();
bundle.putString("user_id", "1111");
sendIntent.putExtra("data", bundle);
sendIntent.setType("text/plain");
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(sendIntent, REQUEST_CODE);
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
Bundle bundle = data.getBundleExtra("data");
String username = bundle.getString("user_name");
result.success(username);
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
I had two activity in App2 ie. MainActivity and LoginActivity.
App2 > AndroidManifest.xml
<activity android:name=".LoginActivity">
<intent-filter>
<!--The action has to be same as App1-->
<action android:name="com.example.sender.login" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
Sorry for this I had a little mix up with Java and Kotlin. My second app was in Kotlin, not that it will effect in any way.
App2 > LoginActivity.java
override fun onResume() {
super.onResume()
var userId = "No data received"
val intent = intent
if (intent != null
&& intent.action != null
&& intent.action.equals("com.example.sender.login")
) {
val bundle = intent.getBundleExtra("data")
if (bundle != null) {
userId = bundle.getString("user_id")
userId = " User id is $userId"
}
}
tvMessage.text = "Data Received: $userId"
}
fun onClickBack(view: View) {
val intent = intent
val bundle = Bundle()
bundle.putString("sesion_id", "2222")
intent.putExtra("data", bundle)
setResult(Activity.RESULT_OK, intent)
finish()
}
When you do this:
Intent i2 = new Intent("com.appstore.MainActivity");
i2.setPackage("com.appstore");//the destination packageName
i2.putExtra("Id", "100");
startActivity(i2);
you are calling the single-argument constructor of Intent. In this constructor, the argument is interpreted as the Intent ACTION. You then set the package name in the Intent.
When you call startActivity() with this Intent, Android will look for an Activity that contains an <intent-filter> with the specified ACTION. There are no installed applications that have an Activity defined like this in the manifest:
<activity>
<intent-filter>
<action android:name="com.appstore.MainActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
So Android will not be able to find and launch the Activity that you want.
As you want to specify explicitly the component that you want to use, instead of using the 1-argument Intent constructor, you should do this instead:
Intent i2 = new Intent();
i2.setClassName("com.appstore", "com.appstore.MainActivity");
i2.putExtra("Id", "100");
startActivity(i2);
Using setClassName() you provide the package name and the class name of the component that you want to launch.
This should work:
APP1
Intent i2 = new Intent();
i2.setComponent(new ComponentName(PACKAGE,ACTIVITY));//the destination packageName
i2.putExtra("Id", "100");
startActivity(i2);
APP2
String myString = getIntent().getStringExtra("Id");
Using Bundle.putSerializable(Key,Object); and Bundle.putParcelable(Key, Object);
the former object must implement Serializable, and the latter object must implement Parcelable.
Content providers:
Content providers are the standard interface that connects data in one process with code running in another process.
See Android Docs.
Content provider working demo here.
Ok so I've been bangin away at my first Android app and the NFC has been very hit and miss. I'm able to successfully pickup on plain text type records, but when I switch over to try to pickup on uri records the phone's browser keeps opening rather than my app. I'm clueless at this point so here's what I got...
<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>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="http" android:host="google.com"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
When I read the tag, I get a new intent but it's action type is "MAIN". Is it just being relaunched? And if so why doesn't the text record do the same? I've tried multiple uri records and every time I get this behavior. Here is part of the java src.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent launchIntent = getIntent();
String action = launchIntent.getAction();
if(action.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) {
Log.i(tag, "MATCH!");
}
nfcAdapter = NfcAdapter.getDefaultAdapter(this);
nfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
tagDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
tagDetected.addDataScheme("http");
tagDetected.addDataAuthority("google.com", null);
filters = new IntentFilter[] { tagDetected };
techArray = new String[][] {
new String[] {
IsoDep.class.getName()
},
new String[] {
NfcB.class.getName()
},
new String[] {
Ndef.class.getName()
}
};
}
public void onResume(){
super.onResume();
nfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, filters, techArray);
Intent launchIntent = getIntent();
String action = launchIntent.getAction();
if(action.equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) {
Log.i(tag, "MATCH!");
} else if(action.equals(NfcAdapter.ACTION_TECH_DISCOVERED)) {
Log.i(tag, "TECH DISCOVERED");
} else if(action.equals(NfcAdapter.ACTION_TAG_DISCOVERED)) {
Log.i(tag, "TAG DISCOVERED");
}
Parcelable[] msg = launchIntent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
//byte[] payloadData = msg.getRecords()[0].getPayload();
//Log.i(tag, "NUM records = " + Integer.toString(msg.getRecords().length));
}
public void onPause() {
super.onPause();
nfcAdapter.disableForegroundDispatch(this);
}
Another interesting note is that when I don't include the list of technologies in the enableForegroundDispatch() call, then the app doesn't pickup any intents resulting from NFC at all (when trying to read uri records). Any ideas oh wise internet?!
With ForegroundDispatch enabled, the intent will arrive through onNewIntent(), so you need to override that method in your activity to receive the NFC intent.
You also need to make sure that the hostname matches exactly. If the tag contains "www.google.com", your intent filter should contain the same name: <data android:scheme="http" android:host="www.google.com"/> and tagDetected.addDataAuthority("www.google.com", null).