How to use method onNewIntent(Intent intent) inside a Fragment?
onNewIntent
belongs to Activity so you cannot have it in your fragment. What you can do is pass the data to your fragment when it arrives in onNewIntent
provided you have the reference to the fragment.
Fragment fragment;
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// Check if the fragment is an instance of the right fragment
if (fragment instanceof MyNFCFragment) {
MyNFCFragment my = (MyNFCFragment) fragment;
// Pass intent or its data to the fragment's method
my.processNFC(intent.getStringExtra());
}
}