I have a notification in notification bar and i have 3 fragments in one of my activity. i want when i click the notification it will open particular fragment, Like what facebook notification do. I tried to search it on google n everywhere else but didnot match what i need.
Example: i have 3 fragments
1 - for redeem value.
2 - for recharge.
3 - for anything.
Now if i get notification from Admin Panel like you can redeem your value, then that notification will open that particular fragment. If i get notification to recharge then it will open that particular fragment like this i want all working.
Hope you clear, if not then please let me know.
you can use this link for open notification in fragment you should use Pending Intent for it and set your fragment with name and open it with pending intent, link1
link2
Related
popup message feature like whats app, caller id like the true caller, I am trying to make the same thing.
I tried using a broadcast receiver but I do not know how to show the dialog box when a broadcast receives a notification.
a pop-up message like WhatsApp shows when a notification arrives on a phone.
Set mainactivity as a launcher screen. In the mainactivity before setContentView method calling check if the intent has extra parameters as per your requirement. If yes, then finish the current activity and start DialogActivity.
I was reading and I can['t get to an answer, I want to send a push notification to my user, but when the user clicks open a custom intent, I don't want to do this for all the notifications, just for a couple. Let's say I want to send here
The value to open a custom intent, and then if I don't put anything there, the app will still open the default intent, I need this because I want to send the user sometimes to another activity
One of the way to achieve this is to always open the MainActivity and pass the information in your notification data(called as payload schema) to the MainActivity as an intent. In your payload schema you will pass in the information which will help you decide which activity to open. These information will be in form of key value pair. For example you can define a parameter action and this will contain an identifier for the activity that you want to open when the notification is clicked.
In your main activity you will have a logic to read this information from your notification schema and redirect it to appropriate activity. Something like this
//Main activity code
public void onResume() {
super.onResume();
if(action == "Activity1") {
//start activity 1;
}
}
If you dont pass anything in notification it will by default launch the main activity.
Any one can tell me how could i get inbuild notification listner in android. What all i want is if user put password on screen and if then some notification arrives. and if user click on notification, I want password field should be reset.
See http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CreateNotification to create a local notification.
In the intent you use for the notification add an extra bit of data that you define (e.g. "ClearPassword" as a boolean of true).
In your activity, check for extras and your specific extra and if it is set then you can clear the field.
Why don't you just clear the password field in the onPause method of the activity? If the user clicks on the notification, the pending intent will launch a new activity (most in the cases from another application). When your activity is no longer the foreground activity, its onPause method will be called.
I have an app that has a notification generator. I'm able to receive and generate multiple notifications. my problem now is how can I know which notification that was clicked by user? each notification might act differently, and there might be at most 5 notifications at the same time in my app. I've searched online and found nothing about onClick event with notification....
I found thatonNewIntent can help, but it is not stable...since the activity might get killed by system before user clicks the notification.
can someone please help??
thanks!!
I suggest you make add data to the intent you add to the notification's intent.
For example.
intent.putExtra("Notification_id", id) //You can make this id the system time or some unique identifier.
(Or you can add this to your bundle of extras instead of just putting the extra.)
Then when you go to open the intent you can check the id.
id = intent.getExtra("Notification_id")
Hope this helps. Let me know if you have any questions or need more details.
UPDATE: You have to add data for in the intent and read it later both in your onNewIntent() and onResume(). You then remove the extra from the intent after you did whatever it is you need to do. Also adding some kind of unique data like System.currentTimeMillis() then it will prevent the intent from being reused.
I have a fairly basic android app that is a tabhost of 4 tabs, each one opens a webview. The app also has GCM all setup and currently can receive messages fine. When a message is received though, you click on it and it simply opens the app the same way clicking on the App icon would open the app. What I am trying to do though is open a particular tab inside the app when someone clicks on message and what would be even better is if I could open any tab depending on what the message is. Is this possible? If so, how would I go about doing this?
From what I have found so far, I think this involves something with adding an additional item in the payload of the message such as
{
"registration_id" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"data" : {
"message" : "Text notification goes here",
"tab" : "2"
},
}
and then possibly doing something with the intents which I am not sure how to do. Am I on the right track and can anyone help me with this?
You can add an extra to the pending intent that you pass to the notification that will indicate which tab to open.
And when the activity starts check for that extra and open the tab accordingly.