2011-01-07 56 views
0

我创建了一个应用程序,轮询服务器以获取必须发送给我们用户的短信。对于轮询功能,我已经使用了报警经理解雇每5分钟轮询服务器Android闹钟管理器不能在三星Galaxy手机上工作

AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); 
     Intent pintent = new Intent(this, SMSSender.class); 
     PendingIntent pIntent = PendingIntent.getBroadcast(this,0,pintent, 0); 
     if(checkbox.isChecked()) { 
      long interval = 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000"));//5mins;//5mins 
      long firstPoll = SystemClock.elapsedRealtime() + 60*Integer.valueOf(PreferenceManager.getDefaultSharedPreferences(this).getString("pref_poll_interval", "5000")); 
      alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstPoll, interval, pIntent); 
      Log.d("SMS_GATEWAY", "alarm manager turned on "+interval); 
     }else { 
      alarm.cancel(pIntent); 
      Log.d("SMS_GATEWAY", "alarm manager turned off"); 
     } 

我已经测试了针对2.2构建模拟器的应用,一切工作正常,现在测试最终出来的短信会我已经在三星Galaxy S手机上安装了该应用程序。

一旦安装了应用程序,并且选择了轮询服务器的优先选项,则什么都不会发生。

可能是什么问题

+0

我有问题(许多! )在三星Galaxy S设备中,在这种情况下,我遇到了读取默认共享prefs的问题,并在logcat中看到以下日志消息 - 您是否也看到了这一点?“W/ApplicationContext(4563):尝试阅读 首选项文件/dbdata/databases/.../ shared_prefs /..._ preferences.xml没有 权限“ 此外,我发现一些引用这只bei在2.2.1上有问题 - 你在什么版本上? – DustinB 2011-01-25 20:19:39

回答

0

考虑为您的问题使用BuzzBox SDK库。

​​

您可以安排使用一个cron字符串任务:

SchedulerManager.getInstance() 
    .saveTask(this, "*/5 8-19 * * 1,2,3,4,5", YourTask.class); 

我有一个Galaxy S的,我在我的几个应用程序的使用BuzzBox SDK。 您可以检查集成在SDK中的计划程序日志以验证您的任务是否正常运行。