I've a problem with my application. I use a class to manage push notification from Azure, extending NotificationsHandler.All works,the method onReceive "catch" the incoming notification,using bundle i can read each field of the json from azure server.If i click on the notification i can start the activity as follows:
fragment_richiesta_tabsV2 dettaglioTabs= new fragment_richiesta_tabsV2();
Intent myIntent = new Intent(contesto, dettaglioTabs.getClass());
contentIntent = PendingIntent.getActivity(contesto, 0,myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
the problem is when the app is closed from the recent apps.The notification arrives,but if i click on the app crash...how can i solve?
thanks
Related
This question already has answers here:
Open application after clicking on Notification
(12 answers)
Closed 3 years ago.
I have an android app which uses FCM for push notifications. There is a backend that sends push notifications
Every time user makes an image upload , a push notification is sent to whoever is subscribed to the topic.
On click of the notification in the notification tray I'm redirected to the first page of the app.
How can I make the push notifications work like how Instagram does.
On receiving a notification and clicking on it , I want to move to that particular screen and see the image that got uploaded.
If the user is in the app while the notification arrives. How to refresh the activity to display the content. Do I have to make a backend request to show the new data or can I display content from the notification itself?
Is there any example I can look at.
Any help will be appreciated. Thank you.
To start an activity that includes a back stack of activities, you need to create an instance of TaskStackBuilder and call addNextIntentWithParentStack(), passing it the Intent for the activity you want to start.
As long as you've defined the parent activity for each activity as described above, you can call getPendingIntent() to receive a PendingIntent that includes the entire back stack.
// Create an Intent for the activity you want to start
Intent resultIntent = new Intent(this, ResultActivity.class);
// Create the TaskStackBuilder and add the intent, which inflates the back
stack
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntentWithParentStack(resultIntent);
// Get the PendingIntent containing the entire back stack
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
I work with NotificationListener and I have a question.
Can I figure out if a notification was removed by the user and not by the app?
I believe you mean cleared by the user from the notification drawer. Yes you can get this information using setDeleteIntent()
The above mentioned API triggers a callback when the notification is cleared.
Intent finalIntent = new Intent(context, PushWorker.class);
finalIntent.putExtras(extras);
finalIntent.setAction(MoEPushWorker.NOTIFICATION_CLEARED);
PendingIntent intent =
PendingIntent.getService(context, 123, finalIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setDeleteIntent(intent);
Here PushWorker is the service in which the callback will be received.
I am implementing push notification using Xamarin. The push notification works fine and I can able to receive a push notification. When I click notification message the corresponding page is not open instead loading pop is showing for a long time. I have used the below code to open activity when clicking notification in android project. I want to call the method which is in the portable project from my new activity class.
Intent intent = new Intent(context, typeof(Push));
intent.AddFlags(ActivityFlags.ClearTop);
PendingIntent activity = PendingIntent.GetActivity(context, 0, intent, 0);
I have called the view in portable project like below
public void test(parameters)
{
await Navigation.PushModalAsync(new DescriptionPage(tileGrid,
m_eBookShortName, m_eBookName, false, downloadImage, deleteImageIcon,
m_downloadProgressbar));
}
What is the issue in my code? how can we launch xaml view when click push notification?
I have set up a notification that opens a website when you tap it. Here's the part of the code that does it.
Intent resultIntent = new Intent(Intent.ACTION_VIEW);
resultIntent.setData(Uri.parse(m.msg.url));
PendingIntent pending = PendingIntent.getActivity(context, 0,
resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notif.setContentIntent(pending);
The notifiaction corresponds to a notification in a website, wich also corresponds to a message in that website. So when you tap the (Android) notification, you go to that website. But I also want to remove the (website) notification by sending a GET request. I already have set a method that does that:
m.delete();
However, I can't find a way to execute both actions at once. The intent should open m.msg.url and execute m.delete(). I have searched for information on Intents and Services but I'm new to Android programming and I don't quite understand how it works. I'd really aprecciate any help or guidance.
Thanks for reading.
Create an Activity or Service that performs the GET then immediately starts the activity you really want to start. Use that as the PendingIntent instead.
i'm a beginner in android , so excuse me for a perhaps stupid question. I'm developing an App with different Features, wich are chosen in the Menu. By google cloud Messaging the App is also receiving push notifications, which are Stored in an MySQL database. These notifications can be shown in a second listactivity. Now my Problem: when this activity is open and a notification is coming in, it is Stored in database, but the aktive listactivity is not updating, Cause it doesn't know. Howe can i Force my listactivity to Refresh from mainactivity when mainactivity is receiving a notificatipn ? Thanks from Germany Fritz
You can post o a notification (for example from a Service) and pass an intent to the corresponding pendingintent.
Intent intent = new Intent(this, MyListActivity.class);
intent.setAction(Intent.ACTION_VIEW);
PendingIntent pi = PendingIntent.getActivity(this, my_code, intent, PendingIntent.FLAG_UPDATE_CURRENT);
...
notificationManager.notify(my_notification);
And in your MyListAcitity you can override the method onNewIntent and reload your data.