android.app.Activity.setResult()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(309)

本文整理了Java中android.app.Activity.setResult()方法的一些代码示例,展示了Activity.setResult()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.setResult()方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:setResult

Activity.setResult介绍

暂无

代码示例

代码示例来源:origin: facebook/stetho

private void setResult(Activity activity) {
  if (wasUserDisconnect()) {
   activity.setResult(RESULT_CANCELED);
  } else {
   activity.setResult(
     RESULT_OK,
     new Intent(activity, IRCChatActivity.class)
       .putExtra(EXTRA_RESULT_CONNECT_ERROR, connectError));
  }
 }
}

代码示例来源:origin: journeyapps/zxing-android-embedded

protected void returnResultTimeout() {
  Intent intent = new Intent(Intents.Scan.ACTION);
  intent.putExtra(Intents.Scan.TIMEOUT, true);
  activity.setResult(Activity.RESULT_CANCELED, intent);
  closeAndFinish();
}

代码示例来源:origin: wangdan/AisenWeiBo

private void savePics() {
  Intent data = new Intent();
  data.putExtra("pics", selectedFile.toArray(new String[0]));
  getActivity().setResult(Activity.RESULT_OK, data);
  getActivity().finish();
}

代码示例来源:origin: facebook/facebook-android-sdk

if (categories == null) {
 activity.setResult(Activity.RESULT_CANCELED, null);
 activity.finish();
 return;
 resultIntent.putExtra(EXTRA_METADATA, shareToMessengerParams.metaData);
 resultIntent.putExtra(EXTRA_EXTERNAL_URI, shareToMessengerParams.externalUri);
 activity.setResult(Activity.RESULT_OK, resultIntent);
 activity.finish();
} else {
 activity.setResult(Activity.RESULT_CANCELED, null);
 activity.finish();

代码示例来源:origin: ankidroid/Anki-Android

private void closeStudyOptions(int result) {
  Activity a = getActivity();
  if (!mFragmented && a != null) {
    a.setResult(result);
    a.finish();
    ActivityTransitionAnimation.slide(a, ActivityTransitionAnimation.RIGHT);
  } else if (a == null) {
    // getActivity() can return null if reference to fragment lingers after parent activity has been closed,
    // which is particularly relevant when using AsyncTasks.
    Timber.e("closeStudyOptions() failed due to getActivity() returning null");
  }
}

代码示例来源:origin: facebook/facebook-android-sdk

private void finishActivity(int resultCode, Intent data) {
  if (currentRequestState != null) {
    DeviceRequestsHelper.cleanUpAdvertisementService(currentRequestState.getUserCode());
  }
  FacebookRequestError error = data.getParcelableExtra(EXTRA_ERROR);
  if (error != null) {
    Toast.makeText(getContext(), error.getErrorMessage(), Toast.LENGTH_SHORT).show();
  }
  if (isAdded()) {
    Activity activity = getActivity();
    activity.setResult(resultCode, data);
    activity.finish();
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  position = position - ((ListView) getRefreshView()).getHeaderViewsCount();
  FriendMentionDB.addFriend(getAdapterItems().get(position));
  Intent data = new Intent();
  data.putExtra("bean", getAdapterItems().get(position));
  getActivity().setResult(Activity.RESULT_OK, data);
  getActivity().finish();
}

代码示例来源:origin: journeyapps/zxing-android-embedded

protected void returnResult(BarcodeResult rawResult) {
  Intent intent = resultIntent(rawResult, getBarcodeImagePath(rawResult));
  activity.setResult(Activity.RESULT_OK, intent);
  closeAndFinish();
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
protected void onSuccess(AccountBean accountBean) {
  super.onSuccess(accountBean);
  if (isActivityRunning()) {
    showMessage(R.string.login_success);
    Logger.d(TAG, "授权成功");
    Intent data = new Intent();
    data.putExtra("account", accountBean);
    getActivity().setResult(Activity.RESULT_OK, data);
  }
}

代码示例来源:origin: seven332/EhViewer

@Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    String key = preference.getKey();
    if (Settings.KEY_THEME.equals(key)) {
      ((EhApplication) getActivity().getApplication()).recreate();
      return true;
    } else if (Settings.KEY_APPLY_NAV_BAR_THEME_COLOR.equals(key)) {
      ((EhApplication) getActivity().getApplication()).recreate();
      return true;
    } else if (Settings.KEY_GALLERY_SITE.equals(key)) {
      getActivity().setResult(Activity.RESULT_OK);
      return true;
    } else if (Settings.KEY_LIST_MODE.equals(key)) {
      getActivity().setResult(Activity.RESULT_OK);
      return true;
    } else if (Settings.KEY_DETAIL_SIZE.equals(key)) {
      getActivity().setResult(Activity.RESULT_OK);
    } else if (Settings.KEY_THUMB_SIZE.equals(key)) {
      getActivity().setResult(Activity.RESULT_OK);
    } else if (Settings.KEY_SHOW_TAG_TRANSLATIONS.equals(key)) {
      if (Boolean.TRUE.equals(newValue)) {
        EhTagDatabase.update(getActivity());
      }
    }
    return true;
  }
}

代码示例来源:origin: seven332/EhViewer

Context context = preference.getContext();
if (context instanceof Activity) {
  ((Activity) context).setResult(Activity.RESULT_OK);

代码示例来源:origin: TommyLemon/APIJSON

}else if (message.what == R.id.return_scan_result) {
  Log.d(TAG, "Got return scan result message");
  activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
  activity.finish();
}else if (message.what == R.id.launch_product_query) {

代码示例来源:origin: TommyLemon/Android-ZBLibrary

}else if (message.what == R.id.return_scan_result) {
  Log.d(TAG, "Got return scan result message");
  activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
  activity.finish();
}else if (message.what == R.id.launch_product_query) {

代码示例来源:origin: wangdan/AisenWeiBo

protected void onSuccess(Favority result) {
  super.onSuccess(result);
  if (getRealActivity() == null) {
    return;
  }
  Intent intent = new Intent();
  intent.setAction("org.aisen.weibo.sina.FAV_DESTORY");
  intent.putExtra("statusId", result.getStatus().getId());
  getRealActivity().setResult(Activity.RESULT_OK, intent);
  GlobalContext.getInstance().sendBroadcast(intent);
  ViewUtils.showMessage(getRealActivity(), R.string.biz_fav_removed);
  if (callback != null)
    callback.onFavorityDestory(result);
};

代码示例来源:origin: seven332/EhViewer

} else if (KEY_IMPORT_DATA.equals(key)) {
  importData(getActivity());
  getActivity().setResult(Activity.RESULT_OK);
  return true;

代码示例来源:origin: facebook/facebook-android-sdk

@Test
public void testFinishShareToMessengerWithUnexpectedIntent() throws Exception {
 // Simulate an intent that Messenger would send.
 Intent originalIntent = new Intent();
 when(mMockActivity.getIntent()).thenReturn(originalIntent);
 // Setup the data the app will send back to messenger.
 Uri uri = Uri.parse("file:///foo.jpeg");
 Uri externalUri = Uri.parse("http://example.com/foo.jpeg");
 ShareToMessengerParams params = ShareToMessengerParams
   .newBuilder(uri, "image/jpeg")
   .setMetaData("{}")
   .setExternalUri(externalUri)
   .build();
 // Call finishShareToMessenger and verify the results.
 MessengerUtils.finishShareToMessenger(mMockActivity, params);
 verify(mMockActivity).setResult(Activity.RESULT_CANCELED, null);
 verify(mMockActivity).finish();
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
protected void onFailure(TaskException exception) {
  super.onFailure(exception);
  if (isActivityRunning()) {
    showMessage(R.string.login_faild);
    Logger.d(TAG, "授权失败 " + exception.getMessage());
    getActivity().setResult(Activity.RESULT_CANCELED);
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  MentionSuggestionBean bean = getAdapterItems().get(position);
  
  WeiBoUser friend = bean.getUser();
  if (friend == null) {
    friend = new WeiBoUser();
    friend.setIdstr(bean.getSuggestUser().getUid());
    friend.setScreen_name(bean.getSuggestUser().getNickname());
    
    new UserShowTask().execute(friend.getScreen_name());
  }
  else {
    FriendMentionDB.addFriend(friend);
  }
  
  Intent data = new Intent();
  data.putExtra("bean", friend);
  getActivity().setResult(Activity.RESULT_OK, data);
  getActivity().finish();
}

代码示例来源:origin: facebook/facebook-android-sdk

verify(mMockActivity).setResult(eq(Activity.RESULT_OK), intentArgumentCaptor.capture());
verify(mMockActivity).finish();

代码示例来源:origin: google/santa-tracker-android

public static void finishActivityWithResult(Context context, int resultCode, Bundle extras) {
    Activity activity = getActivityFromContext(context);
    Intent intent = activity.getIntent();
    intent.putExtras(extras);
    activity.setResult(resultCode, intent);
    activity.finish();
  }
}

相关文章

Activity类方法