appwidgetprovider可以实现onactivityresult如何使用它?

时间:2013-03-04 12:56:12

标签: android

我需要在appwidget上使用onactivityresult,但我如何使用它?它不叫

公共类MainActivity扩展了AppWidgetProvider实现         OnActivityResultListener {     上下文上下文;

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds) {
    super.onUpdate(context, appWidgetManager, appWidgetIds);
    this.context = context;
    for (int i = 0; i < appWidgetIds.length; i++) {
        int appWidgetId = appWidgetIds[i];
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
        PendingIntent pending = PendingIntent.getActivity(context, 0, intent, PendingIntent.PARCELABLE_WRITE_RETURN_VALUE);
        RemoteViews views = new RemoteViews(context.getPackageName(),
                R.layout.activity_main);

        views.setOnClickPendingIntent(R.id.imageButton1, pending);
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }

}
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);
}

@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {}

1 个答案:

答案 0 :(得分:0)

onActivityResult()仅适用于Activity及其子类。这是因为startActivityForResult()仅在Activity及其子类上可用。