I'm even not sure I've written the title correctly, because this is the first time I feel I have to cope with this methods.
In onCreate()
, I make a notification with default sound printing a string. Then, I check to see if I get another String
. If it isn't equal to the previous String
, I make another notification with sound. That is, when I find that I change my location, I make a notification with sound.
The problem is that I want my app to run when it is in background, but as I pause the app, the notification with sound comes immediately (the system doesn't remember that I've already made a notification for that string, it makes another one). And again, as I open the app, I again get the notification.
I want to make only 1 notification for one location even if I close and open app 100 times.
How can I do this?
Hope I could explain the problem.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.map);
//here are being called location listeners
somefunction();
}
public void somefunction(){
//finally, after some operation I get a string
if(newString!=oldString)
{
oldString=newString;
notification();
}
}
public void notification(){
// here I make notification with default audio
}