last day (14 days later) » 

4:35 AM
0
Q: I can not reset the static variable after clicking on the notification

Pavel PetrashovI have 3 types of notifications. Each has its own unique ID, which I give to the server. There's also a 3 static variables that I use to count notifications. Everything is working as I need to. But when I open the program by clicking on one of the notifications and then again to collapse, comes a...

 
which static variable you want to reset ? Does it reside in same class ? Specify it
 
private static int ID_CHECKIN =1; private static int ID_CHECKOUT =1; private static int ID_NEW_COMMENT =1; these variables I want to reset at the moment when the tap the notification
 
reset GCMIntentService.ID_NEW_COMMENT =0 (whatever value you want) in generateNotification.. what issue ?
 
code that I wrote works as I need to. when a message comes in the desired type its number increases. But when I click on the notification and open the program, I need to make new notice starts again from 1. For this I want to reset static variables after the notice has been opened
 
It must be opening any Activity. right ?
 
4:35 AM
he opens it, an
 
@PavelPetrashov what ?
 
I have 5 types of notifications.
to distinguish them I bring ID,
int groupid = Integer.parseInt(intent.getStringExtra("group_id"));
when new messages arrive, I simply update these notifications
and increase their number
public static int ID_CHECKIN =1;
public static int ID_CHECKOUT =1;
public static int ID_NEW_COMMENT =1;
public static int ID_LOGBOOK =1;
public static int ID_WALKIN =1;
5 is static variables are responsible for the number of messages
 
OKie
now when you click it, you wanna reset it
 
when a message arrives, I check as what type it is and form a new notification
protected void onMessage(Context context, Intent intent) {
// Log.d(TAG, "Поступило сообщение: " + intent.getExtras()+" id: "+ id);
String title = intent.getStringExtra("title");
String message = intent.getStringExtra("content");
int groupid = Integer.parseInt(intent.getStringExtra("group_id"));
switch (groupid){
case 0:
generateNotification(context,title, message,groupid,0);
break;
case 1:
generateNotification(context,title, message,groupid,ID_CHECKIN++);
break;
case 2:
generateNotification(context,title, message,groupid,ID_CHECKOUT++);
When I click on any group or a notice that such number is already equal to 3 or 5 or 10, opens the main Activiti.
But in this moment I want to reset the desired variable that is responsible for this group
for example if a CHECKIN is zeroed public static int ID_CHECKIN =1;
 
in MainActivity, can you get what type of notification it is ?
are you facing issue just to reset or distinguish which var to reset ?
 
4:45 AM
I do not know how to do it. You gave me the idea and I am now done so
public void onCreate(Bundle savedInstanceState) {

GCMIntentService.ID_CHECKOUT =1;
GCMIntentService.ID_NEW_COMMENT =1;
GCMIntentService.ID_LOGBOOK =1;
GCMIntentService.ID_WALKIN =1;
but then reset all variables
and how to determine the right I can not understand
 
ya got it...you wanna know which type of notification it is
cant u pass groupid in notification ?
try like this :
Intent intent = new Intent(context,MyActivity.class);
intent.putExtra("groupid",groupid );
and get it in MyActivity and code accordingly
@PavelPetrashov got it ?
 
now try
 
ok and let me know
just get it as getIntent().getIntExtra("groupid", 0)
 
yes it is a good option. thank you. but a new problem arose. If the program is already open and I click on the notification, it disappears. and if at that moment that comes new onCreate is not called
 
why disappear? Dint get you
 
4:57 AM
for example, I received the same message type 3 and 2 posts of the second type. I have 2 notice. written in the first 3 in the second written 2. I clicked on the notification of the first type and opened my program. static variable is cleared. but I still hangs notice of the second type. and if I click on it, it just disappears and the variable is not cleansed yet again challenge onCreate
and if at that time a notification comes another type instead of the second one is instead napisnao 3
and if at this moment come another notification instead of the second type is written instead of 1 3
 
if MyActivity is already opened, your onCreate wont be called again
 
Yes I'm talking about it and say))), and since it will not be due to the variable is reset
 
then you sholud not RESET it
 
in principle it is not so important, the main question we decided. thank you!
 
so is it solved ?
@PavelPetrashov have a look here
 
5:03 AM
Well, what I wanted to know in question decided. with the option when Activiti is already open, I will try to understand
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    onNewIntent(getIntent());
}

@Override
public void onNewIntent(Intent intent){
    Bundle extras = intent.getExtras();
    if(extras != null){
        if(extras.containsKey("NotificationMessage"))
        {
            setContentView(R.layout.viewmain);
            // extract the extra-data in the Notification
            String msg = extras.getString("NotificationMessage");
            txtView = (TextView) findViewById(R.id.txtMessage);
 
Yes, I know about it) thanks.
 
try like this
grt...
 
5:30 AM
you still here?
 

last day (14 days later) »