I make an intent service for download data and i want to repeat with 
broadcast receive and alarm manager.How i call my intent service?I try this 
but no work....

public class AlarmActivity extends Activity {

@Overridepublic void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);}
public void startAlert(View view) {

    EditText text = (EditText) findViewById(R.id.time);

    int i = Integer.parseInt(text.getText().toString());

    Intent intent = new Intent(this, MyBroadcastReceiver.class);

    PendingIntent pendingIntent = 
PendingIntent.getBroadcast(this.getApplicationContext(), 234324243, intent, 0);

    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    //alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()
       // + (i * 1000),pendingIntent);

    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, 
System.currentTimeMillis()
                 ,(i*1000),pendingIntent);

   // alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar
    //      .getTimeInMillis(), intervals, pendingIntent);


    Toast.makeText(this, "Alarm set in " + i + " seconds",
        Toast.LENGTH_LONG).show();
  }




public class MyBroadcastReceiver extends BroadcastReceiver {


    @Override

      public void onReceive(Context context, Intent intent) {

          Toast.makeText(context, "Don't panik but your time is up!!!!.",
            Toast.LENGTH_LONG).show();
        // Vibrate the mobile phone
        Vibrator vibrator = (Vibrator)   
context.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(500);

 Intent newIntent = new Intent(context, DownloadService.class)
 newIntent.setData(Uri.parse("http://www.mysite.net/LEDstate.txt";));
 newIntent.putExtra("urlpath", "http://www.mysite.net/LEDstate.txt";);


 context.startService(newIntent);
}
i use downloadservice from vogella IntentService tutorial....and i want to 
convert it for repeat automate service...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to