Android Open Source - AndroidFortunes Alarm Receiver






From Project

Back to project page AndroidFortunes.

License

The source code is released under:

Apache License

If you think the Android project AndroidFortunes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.codechimp.androidfortunes;
/*  w w w.  j av a 2  s  .  c  om*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.util.Log;

import org.codechimp.util.WakeLock;

public class AlarmReceiver extends BroadcastReceiver {
    private static final String TAG = "AlarmReceiver";
    private Context context;

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "Alarm Received");

        this.context = context;
        WakeLock.acquire(context);

        new GetRandomQuoteTask().execute();
    }

    private class GetRandomQuoteTask extends AsyncTask<Void, Void, Quote> {
        @Override
        protected Quote doInBackground(Void... params) {
            Quote q;
            q = CloudyFortunesClient.getCloudyFortunesApiClient().randomQuote();
            return q;
        }

        @Override
        protected void onPostExecute(Quote result) {
            if (result != null)
                NotifyHelper.notify(context, result.getContent());

            WakeLock.release();
        }
    }
}




Java Source Code List

org.codechimp.androidfortunes.AlarmHelper.java
org.codechimp.androidfortunes.AlarmReceiver.java
org.codechimp.androidfortunes.CloudyFortunesApiInterface.java
org.codechimp.androidfortunes.CloudyFortunesClient.java
org.codechimp.androidfortunes.GeneralUserPreferencesFragment.java
org.codechimp.androidfortunes.MainActivity.java
org.codechimp.androidfortunes.MobileListenerService.java
org.codechimp.androidfortunes.NotifyHelper.java
org.codechimp.androidfortunes.OnBootReceiver.java
org.codechimp.androidfortunes.Quote.java
org.codechimp.androidfortunes.SettingsActivity.java
org.codechimp.androidfortunes.WearActivity.java
org.codechimp.androidfortunes.WearListenerService.java
org.codechimp.util.TimePreference.java
org.codechimp.util.WakeLock.java