Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the code which repeat the alarm every day. You will have to take out your needed code from this activity(sorry for that). You can use this code to set alarm which will repeat every day at 9am. You can add same for evening at your expected time.</p> <pre><code>public class AndroidScheduledActivity extends Activity { /** Called when the activity is first created. */ int id = 115; Intent myIntent; PendingIntent pendingIntent; AlarmManager alarmManager; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button buttonStart = (Button)findViewById(R.id.start); myIntent = new Intent(getBaseContext(), MyScheduledReceiver.class); myIntent.putExtra("id", id); pendingIntent = PendingIntent.getBroadcast(getBaseContext(), id, myIntent, 0); alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); buttonStart.setOnClickListener(new Button.OnClickListener(){ public void onClick(View arg0) { // TODO Auto-generated method stub setForMonday(); finish(); }}); } public void setForMonday() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_WEEK,2); calendar.set(Calendar.HOUR,09); calendar.set(Calendar.MINUTE, 00); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); System.out.println("Old is set@ :== " + calendar.getTime()); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pendingIntent); } } </code></pre> <p>Here is the alarm receiver</p> <pre><code>public class MyScheduledReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // here you can add the code to change the background System.out.println("Receiver"); } } </code></pre> <p>Also you will have to add receiver in the manifest file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload