我需要onActivityResult
在启动活动的小部件中使用
public class MainActivity extends AppWidgetProvider implements
OnActivityResultListener {
Context context;
@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, 1);
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.activity_main);
views.setOnClickPendingIntent(R.id.imageButton1, pending);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
}
我需要当我选择联系人时可以在小部件上获得结果