<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>
<provider android:name=".DownloadContentProvider"
android:process=":my_process/>
<service android:name=".DownloadService"
android:process=":my_process/>
</application>
DownloadActivity class that extends
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
"Download File", "Query via query()", "Query via CursorLoader", "Query
via AsyncQueryHandler", and "Reset Image" to run the corresponding
hook methods that use the URL provided by the user to download and
display the designated bitmap file as follows:
DownloadActivity
spawns a Thread (or an AsyncTask) that calls
query() on the ContentResolver to request that the associated
ContentProvider to provide a Cursor containing the file that matches
the URI back to thread, which opens the file and causes the bitmap to
be displayed on the screen.
DownloadActivity
uses a CursorLoader to return a Cursor containing the file that
matches the URI back to thread, which opens the file and causes the
bitmap to be displayed on the screen back to
DownloadActivity as an onLoadFinished() callback, which
opens the file and causes the bitmap to be displayed on the
screen.
DownloadActivity uses an AsyncQueryHandler to return a
Cursor containing the file that matches the URI back to thread, back
to DownloadActivity as an onQueryComplete() callback,
which opens the file and causes the bitmap to be displayed on the
screen.
ContentProvider components must run in different
processes than the 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.
There's a great deal of useful information on Android ContentProviders available on the web and in your textbook, but make sure not to blindly copy and paste it..
Back to CS 282 home page.