indianpoptart / RadioControl

An app that auto toggles wifi and cell radio for maximum battery life
https://nikhilp.org/radiocontrol
GNU General Public License v3.0
16 stars 7 forks source link

AlarmManager #17

Closed indianpoptart closed 7 years ago

indianpoptart commented 8 years ago

Check for link speed, use to disconnect WiFi if link speed is too low

AlarmReceiver

public class AlarmReceiver extends BroadcastReceiver
{   

 @Override
 public void onReceive(Context context, Intent intent)
  {   
    //get and send location information
  }
}

ManifestSnippet

<receiver
    android:name="com.nikhilparanjape.radiocontrol.AlarmReceiver"
    android:exported="false">
</receiver>

AlarmManager

AlarmManager alarmManager=(AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),600000,
                                                                      pendingIntent);
indianpoptart commented 7 years ago

Not required