public class service extends IntentService { ResultSet resultSet; String offerTitle; public static int offerNum = 0; String msg=""; ConnectSQL connectSQL = new ConnectSQL(); public static boolean ServiceIsRun = false; public service() { super("MyWebRequestService"); } @Override protected void onHandleIntent(@Nullable Intent workintent) { while (ServiceIsRun) { try { resultSet = connectSQL.RunSearch("SELECT * FROM offerdetails where offernumber> " + offerNum + " ", this); if (resultSet.next()) { msg= resultSet.getString(1).toString(); offerNum = resultSet.getInt(9); } Intent intent = new Intent(); //set the action that will receive our broadcast intent.setAction("com.example.Broadcast"); // add data to the bundle intent.putExtra("msg", msg); // send the data to broadcast sendBroadcast(intent); } catch (SQLException e) { Toast.makeText(getApplication(), e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } try { Thread.sleep(20000); } catch (Exception ex) { } } }
sendBroadcast()
resultSet
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)