PhotoAppWidgetConfigurepublic class PhotoAppWidgetConfigure extends android.app.Activity
Fields Summary |
---|
private static final String | TAG | static final int | REQUEST_GET_PHOTO | int | appWidgetId |
Methods Summary |
---|
protected void | onActivityResult(int requestCode, int resultCode, android.content.Intent data)
if (resultCode == RESULT_OK && appWidgetId != -1) {
// Store the cropped photo in our database
Bitmap bitmap = (Bitmap) data.getParcelableExtra("data");
PhotoDatabaseHelper helper = new PhotoDatabaseHelper(this);
if (helper.setPhoto(appWidgetId, bitmap)) {
resultCode = Activity.RESULT_OK;
// Push newly updated widget to surface
RemoteViews views = PhotoAppWidgetProvider.buildUpdate(this, appWidgetId, helper);
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this);
appWidgetManager.updateAppWidget(new int[] { appWidgetId }, views);
}
helper.close();
} else {
resultCode = Activity.RESULT_CANCELED;
}
// Make sure we pass back the original appWidgetId
Intent resultValue = new Intent();
resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
setResult(resultCode, resultValue);
finish();
| protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
// Someone is requesting that we configure the given appWidgetId, which means
// we prompt the user to pick and crop a photo.
appWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (appWidgetId == -1) {
setResult(Activity.RESULT_CANCELED);
finish();
}
// TODO: get these values from constants somewhere
// TODO: Adjust the PhotoFrame's image size to avoid on the fly scaling
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 192);
intent.putExtra("outputY", 192);
intent.putExtra("noFaceDetection", true);
intent.putExtra("return-data", true);
startActivityForResult(intent, REQUEST_GET_PHOTO);
|
|