Example usage for android.app Activity setResult

List of usage examples for android.app Activity setResult

Introduction

In this page you can find the example usage for android.app Activity setResult.

Prototype

public final void setResult(int resultCode, Intent data) 

Source Link

Document

Call this to set the result that your activity will return to its caller.

Usage

From source file:io.imoji.sdk.editor.fragment.OutlineTaskFragment.java

private void notifySuccess(String token, Activity a) {
    EditorBitmapCache.getInstance().clearNonOutlinedBitmaps();
    Intent intent = new Intent();
    intent.putExtra(ImojiEditorActivity.CREATE_TOKEN_BUNDLE_ARG_KEY, token);
    a.setResult(Activity.RESULT_OK, intent);
    a.finish();/*from www .ja va  2 s. co m*/
}

From source file:org.firebears.scouting2846.TeamDetailFragment.java

private void onTeamLoaded(Cursor c) {
    if (c == null) {
        Log.d(TAG, "team not found");
        Activity a = getActivity();
        if (a != null) {
            Intent intent = new Intent();
            intent.putExtra(TeamListActivity.ERROR_CODE, R.string.invalid_number);
            a.setResult(Activity.RESULT_CANCELED, intent);
            a.finish();/*from   w  w  w .j av a 2  s  .  c o m*/
        }
        return;
    }
    Log.d(TAG, "team loaded");
    if (null == root_view)
        return;
    Toolbar bar = (Toolbar) getActivity().findViewById(R.id.detail_toolbar);
    if (bar != null) {
        int team_num = c.getInt(c.getColumnIndex(Team.COL_TEAM_NUMBER));
        String nick = c.getString(c.getColumnIndex(Team.COL_NICKNAME));
        bar.setTitle("" + team_num + ' ' + nick);
    }
    setViewText(R.id.locality, c, Team.COL_LOCALITY);
    setViewText(R.id.region, c, Team.COL_REGION);
    setViewText(R.id.country, c, Team.COL_COUNTRY);
    TextView tv = setViewText(R.id.team_website, c, Team.COL_WEBSITE);
    Linkify.addLinks(tv, Linkify.WEB_URLS);
    tv = (TextView) root_view.findViewById(R.id.team_rookie_year);
    String t = c.getString(c.getColumnIndex(Team.COL_ROOKIE_YEAR));
    if (t != null)
        tv.setText(getText(R.string.rookie_year) + " " + t);
    initScoutingSpinner();
    setViewText(R.id.team_motto, c, Team.COL_MOTTO);
}

From source file:io.imoji.sdk.editor.fragment.CreateTaskFragment.java

private void notifySuccess(Imoji result, Activity a) {
    EditorBitmapCache.getInstance().clearNonOutlinedBitmaps();
    Intent intent = new Intent();
    intent.putExtra(ImojiEditorActivity.IMOJI_MODEL_BUNDLE_ARG_KEY, result);
    a.setResult(Activity.RESULT_OK, intent);
    LocalBroadcastManager.getInstance(a)
            .sendBroadcast(new Intent(ImojiEditorActivity.IMOJI_CREATION_FINISHED_BROADCAST_ACTION));
    a.finish();/*  w  w  w  . j  a  va2s  .  com*/
}

From source file:org.csploit.android.core.System.java

public static boolean checkNetworking(final Activity current) {
    if (!Network.isWifiConnected(mContext)) {

        Intent intent = new Intent();
        intent.putExtra(WifiScannerActivity.CONNECTED, false);
        current.setResult(Activity.RESULT_OK, intent);

        String title = current.getString(R.string.error);
        String message = current.getString(R.string.wifi_went_down);

        new FatalDialog(title, message, current).show();

        return false;
    }//from   www  .j av a  2  s  .com

    return true;
}

From source file:com.androidquery.simplefeed.PQuery.java

public void result(Activity act, int resultCode, Intent data) {

    Intent input = act.getIntent();/*from w w w.j  av  a2s.com*/

    if (input != null) {
        data.putExtra(FW_CB, input.getStringExtra(FW_CB));
        data.putExtra(FW_ID, input.getIntExtra(FW_ID, -1));
    }

    act.setResult(resultCode, data);

}

From source file:org.traccar.manager.DevicesFragment.java

private void finishDevicesActivity(long deviceId, String deviceStatus) {
    Activity activity = getActivity();
    Intent deviceIntent = new Intent();
    deviceIntent.putExtra(EXTRA_DEVICE_ID, deviceId);
    deviceIntent.putExtra(EXTRA_DEVICE_STATUS, deviceStatus);

    //activity.setResult(MainFragment.RESULT_SUCCESS, new Intent().putExtra(EXTRA_DEVICE_ID, deviceId ));
    activity.setResult(MainFragment.RESULT_SUCCESS, deviceIntent);
    activity.finish();//from  w w w . j a v a  2s.  c om
}

From source file:org.opensilk.video.tv.ui.playback.PlaybackControlsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PlaybackActivityComponent activityComponent = DaggerService.getDaggerComponent(getActivity());
    mComponent = activityComponent/* www  .j a v a  2  s  . c o  m*/
            .newPlaybackControlsComponent(new PlaybackControlsModule(getActivity(), this));
    mComponent.inject(this);

    setBackgroundType(BG_NONE);

    //init mediaController
    mMediaController = getActivity().getMediaController();
    mMediaController.registerCallback(mMediaControllerCallback);

    //init primary adapter
    ClassPresenterSelector presenterSelector = new ClassPresenterSelector();
    mAdapter = new SparseArrayObjectAdapter(presenterSelector);

    //init controls row
    mControlsRowGlue = new PlaybackControlsGlue(getContext(), this, mMediaController);

    MediaMetadata mediaMetadata = mMediaController.getMetadata();
    if (mediaMetadata != null) {
        mControlsRowGlue.onMetadataChanged(mediaMetadata);
    }

    PlaybackState playbackState = mMediaController.getPlaybackState();
    if (playbackState != null) {
        mControlsRowGlue.onStateChanged(playbackState);
    }

    PlaybackControlsRowPresenter controlsRowPresenter = mControlsRowGlue.createControlsRowAndPresenter();
    PlaybackControlsRow controlsRow = mControlsRowGlue.getControlsRow();
    //        SparseArrayObjectAdapter secondaryActionsAdapter =
    //                new SparseArrayObjectAdapter(new ControlButtonPresenterSelector());
    //        secondaryActionsAdapter.set(5, new PlaybackControlsRow.ClosedCaptioningAction(getContext()));
    //        controlsRow.setSecondaryActionsAdapter(secondaryActionsAdapter);
    presenterSelector.addClassPresenter(PlaybackControlsRow.class, controlsRowPresenter);
    mAdapter.set(CONTROLS_ROW, controlsRow);

    //init overview row
    mOverviewRow = new PlaybackOverviewRow(new HeaderItem("Overview"));
    PlaybackOverviewRowPresenter overviewRowPresenter = new PlaybackOverviewRowPresenter();
    if (playbackState != null) {
        updateOverview(playbackState.getActiveQueueItemId());
    }
    presenterSelector.addClassPresenter(PlaybackOverviewRow.class, overviewRowPresenter);
    mAdapter.set(OVERVIEW_ROW, mOverviewRow);
    Subscription overviewSub = mOverviewObservable.subscribe(info -> {
        mOverviewRow.setItem(info);
    }, e -> {
        Timber.w("videoDescription");
    });
    mSubscriptions.add(overviewSub);

    //init queue row
    QueueAdapter queueRowAdapter = new QueueAdapter();
    List<MediaSession.QueueItem> queue = mMediaController.getQueue();
    if (queue != null) {
        queueRowAdapter.swap(queue);
    }
    CharSequence queueTitle = mMediaController.getQueueTitle();
    if (StringUtils.isEmpty(queueTitle)) {
        queueTitle = "Queue";
    }
    mQueueRow = new ListRow(new HeaderItem(queueTitle.toString()), queueRowAdapter);
    presenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter());
    mAdapter.set(QUEUE_ROW, mQueueRow);

    //init subtitle row
    SubtitleAdapter subtitleAdapter = new SubtitleAdapter();
    mSubtitleRow = new ListRow(new HeaderItem("Subtitles"), subtitleAdapter);
    //not adding yet

    //set adapter
    setAdapter(mAdapter);
    setOnItemViewClickedListener(new ItemClickListener());

    //on new items update the activity result
    Subscription resultSub = mMediaItemObservable.subscribe(item -> {
        Activity activity = getActivity();
        if (activity != null) {
            Intent result = new Intent().putExtra(DetailsActivity.MEDIA_ITEM, item);
            activity.setResult(Activity.RESULT_FIRST_USER + 12, result);
        }
    }, e -> {
        Timber.w(e, "setResult()");
    });
    mSubscriptions.add(resultSub);
}

From source file:org.sufficientlysecure.keychain.ui.EditIdentitiesFragment.java

public void finishWithResult(OperationResult result) {
    Activity activity = getActivity();
    if (activity == null) {
        return;/* ww w . ja v a 2 s  .  c om*/
    }

    Intent data = new Intent();
    data.putExtra(OperationResult.EXTRA_RESULT, result);
    activity.setResult(Activity.RESULT_OK, data);
    activity.finish();
}

From source file:de.persoapp.android.core.adapter.MainViewFragment.java

protected void finish() {
    Activity activity = getActivity();
    if (activity == null) {
        return;//from w w  w  . j a  va  2  s. co  m
    }

    excludeFromRecentAppList(activity);

    if (isAuthenticationSuccess()) {
        if (mRefreshBrowser) {
            sendIntentToBrowser();
        } else {
            activity.setResult(Activity.RESULT_OK,
                    new Intent().putExtra(EXTRA_REFRESH_ADDRESS, mRefreshAddress));
        }
    }

    activity.finish();
}

From source file:com.acc.android.util.widget.adapter.ImageAdapter.java

public ImageAdapter(final Context context,
        // List<Cphoto> cPhotos,
        Gallery gallery, BitmapProviderManager bitmapProviderManager, ACCFileCallback accFileCallback,
        // boolean useOldShowImage,
        boolean useGalleryDeleteAction, boolean isBig) {
    this.context = context;
    this.gallery = gallery;
    // this.cPhotos = new ArrayList<Cphoto>();
    this.isBig = isBig;
    // if (fileDownloadManager == null) {
    // Handler fileDownloadListener = new Handler() {
    // @Override/*w w w. j  av a 2 s.com*/
    // public void handleMessage(final Message msg) {
    // ImageAdapter.this.notifyDataSetChanged();
    // }
    // };
    // // ;
    // fileDownloadManager = new FileDownloadManager(context,
    // fileDownloadListener);
    // }
    this.accFileCallback = accFileCallback;
    this.bitmapProviderManager = bitmapProviderManager;
    // this.gallery.setAdapter(this);
    this.gallery.setVisibility(View.GONE);
    // this.fileDownloadManager = fileDownloadManager;
    this.initGalleryAciton(
            // useOldShowImage,
            useGalleryDeleteAction);
    this.onSingleTapListener = new OnSingleTapListener() {

        @Override
        public void onSingleTap() {
            Intent intent = new Intent();
            intent.putExtras(IntentUtil.getBundle(ACCALibConstant.KEY_BUNDLE_ACC_FILE_S,
                    ImageAdapter.this.getTransImageData()));
            Activity contextActivity = (Activity) context;
            contextActivity.setResult(Activity.RESULT_OK, intent);
            contextActivity.finish();
        }
    };
    this.initImageData();
}