summaryrefslogtreecommitdiffstats
path: root/Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java')
-rw-r--r--Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java26
1 files changed, 12 insertions, 14 deletions
diff --git a/Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java b/Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java
index eebf924..e74daa9 100644
--- a/Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java
+++ b/Android/06-Notifications/Notifications/src/course/labs/notificationslab/MainActivity.java
@@ -17,6 +17,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.widget.Toast;
import android.os.Bundle;
import android.util.Log;
@@ -70,13 +71,10 @@ public class MainActivity extends Activity implements SelectionListener {
log("In ensureData(), mIsFresh:" + mIsFresh);
if (!mIsFresh) {
- // TODO:
- // Show a Toast Notification to inform user that
- // the app is "Downloading Tweets from Network"
log ("Issuing Toast Message");
+ Toast.makeText(MainActivity.this, "Downloading Tweets from Network", Toast.LENGTH_SHORT).show();
- // TODO:
- // Start new AsyncTask to download Tweets from network
+ new DownloaderTask(MainActivity.this).execute(URL_LGAGA, URL_RBLACK, URL_TSWIFT);
// Set up a BroadcastReceiver to receive an Intent when download
// finishes.
@@ -84,10 +82,9 @@ public class MainActivity extends Activity implements SelectionListener {
@Override
public void onReceive(Context context, Intent intent) {
log("BroadcastIntent received in MainActivity");
- // TODO:
- // Check to make sure this is an ordered broadcast
- // Let sender know that the Intent was received
- // by setting result code to RESULT_OK
+ if (isOrderedBroadcast()) {
+ setResultCode(RESULT_OK);
+ }
}
};
} else {
@@ -145,15 +142,16 @@ public class MainActivity extends Activity implements SelectionListener {
@Override
protected void onResume() {
super.onResume();
- // TODO:
- // Register the BroadcastReceiver to receive a
- // DATA_REFRESHED_ACTION broadcast
+ if(mRefreshReceiver != null) {
+ registerReceiver(mRefreshReceiver, new IntentFilter(DATA_REFRESHED_ACTION));
+ }
}
@Override
protected void onPause() {
- // TODO:
- // Unregister the BroadcastReceiver
+ if(mRefreshReceiver != null) {
+ unregisterReceiver(mRefreshReceiver);
+ }
super.onPause();
}