onNewIntent not get called
It is because of the onNewIntent is not being called!!!
I put this on where this activity is get called.
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
then its works like a charm!!.
It is because of calling new activity. And FLAG_ACTIVITY_SINGLE_TOP makes onNewIntent
get called. This FLAG_ACTIVITY_SINGLE_TOP will not start a new Activity.
Android - onNewIntent is not called - singletop activities
onNewIntent(Intent intent)
is only called once before the activity is created. After that It will not call untill you destroy and recreate the activity...
Please see the docs, It will more clarify you,
http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)
Android OnNewIntent not called
Ok got it working soon after posting my question. I think the key difference in our code is that I pass the flag "PendingIntent.FLAG_UPDATE_CURRENT" to the creation/retrieval of the PendingIntent object. This post helped me figure that out.
Notification.Builder mBuilder =
new Notification.Builder(context)
.setSmallIcon(R.drawable.notifyicon)
.setContentTitle(title)
.setContentText(extras.getString("message"))
.setAutoCancel(true)
.setOnlyAlertOnce(false)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setVibrate(new long[] {0,500,250,500});
if(badgeCount > 1)
mBuilder.setNumber(badgeCount);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context, SiteViewActivity.class);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
resultIntent.putExtra(NOTIFY_INTENT_TYPE_KEY, alertType);
PendingIntent resultPendingIntent = PendingIntent.getActivity(context, alertType, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager notifyMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notifyMgr.notify(alertType, mBuilder.build());
onNewIntent is not being called
Add FLAG_ACTIVITY_SINGLE_TOP flag to your intent
(see onNewIntent(Intent intent)).
OnNewIntent not called when starting up an Activity through a NFC tag
Try this:
protected void onCreate(Bundle savedInstanceState) {
//Your stuff
Intent intent = getIntent();
handleIntents(intent);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
handleIntents(intent);
}
private void handleIntents(Intent intent) {
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
//stuff
}
}
Related Topics
How to Check If Running on UI Thread in Android
Android: How to Enable/Disable an Activity's Intent Filter Programmatically
How to Set Up Multiple Listeners for One Event
Android/Eclipse Panic: Could Not Open
Video Compression on Android Using New Mediacodec Library
Write File to Location Other Than Sdcard Using Android Ndk
Copy Database File to Sdcard in Android
How to Merge Two Mp3 Files into One (Combine/Join)
Only One Log in Per User at the Time in Firebase for Android
Android Error - Caused By: Java.Lang.Noclassdeffounderror: Android.Support.V4.Util.Sparsearraycompat
How to Force an Intentservice to Stop Immediately with a Cancel Button from an Activity
How to Integrate Matlab Code Library with Android
Camera in Android, How to Get Best Size, Preview Size, Picture Size, View Size, Image Distorted
Gradle Flavors for Android with Custom Source Sets - What Should the Gradle Files Look Like
Get Current Visible Text in Textview
Firebase Dynamic Link Not Opening the App
Crop Video Before Encoding with Mediacodec for Grafika's "Continuous Capture" Activity