0

I am developing one application in Android. My application has one service. My service is always running in background. My background service keep monitoring of region define by user.

Now when user go out range my application give alert to user. Now my problem is below :

  1. When my application is closed i.e. not running, then my application get alert.
  2. When my application is running then sometimes it get alert and some times not.

Below is the code i.e. activity that will load alert for when user go out of range.

//SecuRemote.LOG("current activity context" + SecuRemote.currentActivityContext);
Intent i = new Intent(context, ShowAlertDialog.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
i.putExtra("Msg",msg);
if(status){
    i.putExtra("status","true");
    if(devName != null)
        i.putExtra("devName",devName);
} else
    i.putExtra("status","false");
    SecuRemote.LOG("start activity showAlertDialog" + context);
    context.startActivity(i);

Looking some good response... Regards,

4

1 回答 1

0

问题可能出在编程逻辑中 -

  1. service可能应该检查是否有一个标志isInside,所以当用户进入您的应用程序时,这个标志将被切换,isInside=true并且onPause or on onDestroy无论您认为什么会达到您的目的,您都应该切换标志

//服务部分和对话框显示

因此,在您service检查标志时,一旦检查isInside=false它就会使用上面提到的代码引发警报....我建议您通过将上述活动(警报活动)显示为对话框该活动的主题属性为对话框 ....

android:theme="@android:style/Theme.Dialog"

我希望它可以帮助你。

于 2013-05-15T05:23:49.410 回答