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:can.yrt.onebusaway.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the stop ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIHelp.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();/*from   www .  j  a  v a  2  s  .  co  m*/

    } else {
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:org.onebusaway.android.ui.MyRouteListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {

    // Get the cursor and fetch the route ID from that.
    SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter();
    Cursor c = cursorAdapter.getCursor();
    c.moveToPosition(position - l.getHeaderViewsCount());
    final String routeId = c.getString(COL_ID);
    final String routeName = c.getString(COL_SHORTNAME);

    if (isShortcutMode()) {
        final Intent shortcut = UIUtils.makeShortcut(getActivity(), routeName,
                RouteInfoActivity.makeIntent(getActivity(), routeId));

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();//from   w  ww. j  a v a2  s  .  c o  m

    } else {
        RouteInfoActivity.start(getActivity(), routeId);
    }
}

From source file:com.justplay1.shoppist.shared.base.activities.BaseActivity.java

public void finishActivityWithResult(Activity activity, int resultCode, Intent data) {
    activity.setResult(resultCode, data);
    finishActivity(activity);/* ww w  .j av  a2 s .  c o m*/
}

From source file:can.yrt.onebusaway.MyStopListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    StopData stopData = getStopData(l, position);

    ArrivalsListActivity.Builder b = stopData.getArrivalsList();

    if (isShortcutMode()) {
        final Intent shortcut = UIHelp.makeShortcut(getActivity(), stopData.getUiName(), b.getIntent());

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();/*from  ww  w  .  j  av a2s.com*/
    } else {
        b.setUpMode(NavHelp.UP_MODE_BACK);
        b.start();
    }
}

From source file:org.onebusaway.android.ui.MyStopListFragmentBase.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    StopData stopData = getStopData(l, position);

    ArrivalsListActivity.Builder b = stopData.getArrivalsList();

    if (isShortcutMode()) {
        final Intent shortcut = UIUtils.makeShortcut(getActivity(), stopData.getUiName(), b.getIntent());

        Activity activity = getActivity();
        activity.setResult(Activity.RESULT_OK, shortcut);
        activity.finish();/*  w ww . j a  v a  2 s  .c  o m*/
    } else {
        b.setUpMode(NavHelp.UP_MODE_BACK);
        b.start();
    }
}

From source file:net.naonedbus.fragment.impl.AddressSearchFragment.java

@Override
public void onListItemClick(final ListView l, final View v, final int position, final long id) {
    final AddressResult item = mAdapter.getItem(position);

    final Intent data = new Intent();
    data.putExtra("address", item.getAddress());
    data.putExtra("latitude", item.getLatitude());
    data.putExtra("longitude", item.getLongitude());
    data.putExtra("type", item.getType());
    data.putExtra("isCurrentLocation", item.isCurrentLocation());

    final Activity activity = getActivity();

    activity.setResult(1, data);
    activity.finish();//from  w w w  .  j  a  v a  2  s .  c o m
}

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

private void notifyFailure(Activity a) {
    EditorBitmapCache.getInstance().clearNonOutlinedBitmaps();
    a.setResult(Activity.RESULT_CANCELED, null);
    a.finish();
}

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

@Override
public void onQueuedOperationSuccess(CertifyResult result) {
    // protected by Queueing*Fragment
    Activity activity = getActivity();

    Intent intent = new Intent();
    intent.putExtra(CertifyResult.EXTRA_RESULT, result);
    activity.setResult(Activity.RESULT_OK, intent);
    activity.finish();//  w w w . j  ava2s .  c o m

}

From source file:com.facebook.share.internal.DeviceShareDialogFragment.java

private void finishActivity(int resultCode, Intent data) {
    DeviceRequestsHelper.cleanUpAdvertisementService(currentRequestState.getUserCode());

    if (isAdded()) {
        Activity activity = getActivity();
        activity.setResult(resultCode, data);
        activity.finish();//  w w  w.j a va2s . co m
    }
}

From source file:it.cosenonjaviste.mv2m.ViewModelManager.java

public void onBackPressed(Activity activity) {
    ActivityResult result = viewModel.onBackPressed();
    if (result != null) {
        Intent intent = new Intent();
        intent.putExtra(RESULT_DATA, result.getData());
        activity.setResult(result.isResultOk() ? Activity.RESULT_OK : Activity.RESULT_CANCELED, intent);
    }//from w  w  w  .ja v  a 2s  .  co  m
}