|
|
|
|
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name="DownloadActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/%gt;
</intent-filter>
</activity>
<service android:name="ThreadedDownloadService"
android:process=":myProcess1/>
<service android:name="ThreadPoolDownloadService"
android:process=":myProcess2/>
<service android:name="DownloadIntentService"
android:process=":myProcess3/>
</application>
DownloadActivity class that inherits
from Activity and uses the XML layout containing a
TextView object that prompts for the URL of the bitmap
file and stores the entered URL in an EditText
object.
Button objects with the labels "Run
IntentService Messenger", "Run ThreadPool Messenger", "Run Thread
PendingIntent", "Run Async Receiver", and "Reset Image" to run the
corresponding hook methods that use the URL provided by the user to
start Service(s) that download the designated bitmap file via the
following Android concurrency and response models:
IntentService to download the designated bitmap file,
stores it in the Android file system, and use a Messenger
to send the filename back to the DownloadActivity
process, which opens the file and displays the bitmap on the screen.
ThreadPoolExecutor (e.g., via the
ExecutorService configured with at least 4 threads using
the newFixedThreadPool() method) to download the designated bitmap
file, stores it in the Android file system, and use a
Messenger to send the filename back to the
DownloadActivity process, which opens the file and
displays the bitmap on the screen.
PendingIntent to send the filename back
to the DownloadActivity process via it's
onActivityResult() method, which opens the file and
displays the bitmap on the screen.
AsyncTask that downloads the designated bitmap file,
stores it in the Android file system, and use
sendBroadcast() to send the filename back to a
BroadcastReceiver in the DownloadActivity
process, which opens the file and displays the bitmap on the
screen.
DownloadActivity component.
Button objects that initiate the downloading of
the bitmap file must be connected to the corresponding
DownloadActivity.run*() methods via the appropriate
android:onClick="..." attributes.
TextView,
EditText, or Button objects into your
DownloadActivity class.
Utils class.
DownloadActivity process. There's a great deal of useful
information on Android Services available on the web, but make sure
not to blindly copy and paste it..
Back to CS 282 home page.