Example usage for android.support.v4.app FragmentActivity startActivityForResult

List of usage examples for android.support.v4.app FragmentActivity startActivityForResult

Introduction

In this page you can find the example usage for android.support.v4.app FragmentActivity startActivityForResult.

Prototype

@Override
public void startActivityForResult(Intent intent, int requestCode) 

Source Link

Document

Modifies the standard behavior to allow results to be delivered to fragments.

Usage

From source file:io.realm.realmtasks.auth.google.GoogleAuth.java

public GoogleAuth(final SignInButton btnSignIn, final FragmentActivity fragmentActivity) {
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail().requestIdToken(fragmentActivity.getString(R.string.server_client_id)).build();

    mGoogleApiClient = new GoogleApiClient.Builder(fragmentActivity)
            .enableAutoManage(fragmentActivity /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();

    btnSignIn.setOnClickListener(new View.OnClickListener() {
        @Override//  w  w w  .  ja v  a  2  s.c o m
        public void onClick(View v) {
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            fragmentActivity.startActivityForResult(signInIntent, RC_SIGN_IN);
        }
    });
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

private ImageView getImageView(final Context context, Bitmap photo, String uuid) {
    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight));
    imageView.setPadding(5, 5, 5, 5);// www.  j  ava 2  s. co m
    imageView.setImageBitmap(photo);
    imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px));
    imageView.setTag(uuid);
    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String photoId = (String) v.getTag();

            FragmentActivity activity = mFragmentDetail.getActivity();
            Intent intent = new Intent(activity, PictureActivity.class);

            if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session
                intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId));
            } else if (_pictures.containsKey(photoId)) {// pictures from database

                Map<String, String> imagePaths = _pictures.get(photoId);
                String imagePath = imagePaths.get("display");

                intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path
            }
            if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW)
                    || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) {
                intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId);
                activity.startActivityForResult(intent, PICTURE_VIEW_RESULT);
            } else
                Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show();

            /*
            JSONArray form = null;
            try {
            form = mFragmentDetail.getSelectedForm();
            } catch (JSONException jse) {
            jse.printStackTrace();
            Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show();
            }
                    
            if (form != null) {
            try {
                String json = encodeToJson();
                FormUtilities.updatePicture(form, json);
            } catch (JSONException e) {
                e.printStackTrace();
            }catch (Exception e) {
                e.printStackTrace();
            }
            }
            try {
            refresh(getContext());
            } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
            }*/
            /**
             * open in markers to edit it
             */
            // MarkersUtilities.launchOnImage(context, image);
            /* try {
                 Intent intent = new Intent();
                 intent.setAction(Intent.ACTION_VIEW);
                 Image image = imagesDbHelper.getImage(imageIdLong);
                 File tempDir = ResourcesManager.getInstance(context).getTempDir();
                 String ext = ".jpg";
                 if (image.getName().endsWith(".png"))
                     ext = ".png";
                 File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext));
                 byte[] imageData = imagesDbHelper.getImageData(image.getId());
                 ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath());
                    
                 intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$
                                                                             context.startActivity(intent);
                                                                             } catch (Exception e) {
                                                                             //GPLog.error(this, null, e);
                                                                             Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                                                                             }*/
            //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show();

        }
    });
    return imageView;
}

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

private void onTweetFeedItemSingleTap(View view, int position) {

    if (mSelectedItems.size() == 0) {
        TweetFeedItemView tweetFeedItemView = (TweetFeedItemView) (view);
        TwitterStatus status = tweetFeedItemView.getTwitterStatus();
        FragmentActivity activity = getActivity();
        if (activity != null) {
            Intent tweetSpotlightIntent = new Intent(activity, TweetSpotlightActivity.class);
            tweetSpotlightIntent.putExtra("statusId", Long.toString(status.mId));
            tweetSpotlightIntent.putExtra("status", status.toString());
            tweetSpotlightIntent.putExtra("clearCompose", "true");
            activity.startActivityForResult(tweetSpotlightIntent, Constant.REQUEST_CODE_SPOTLIGHT);
        }/* w  w w. ja va  2 s .  co  m*/
    } else {
        onTweetFeedItemLongPress(view, position);
    }
}