Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8018813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:13:07+00:00 2026-06-04T21:13:07+00:00

i learn android and i am a beginner, i tried to get a pic

  • 0

i learn android and i am a beginner,
i tried to get a pic and turn it to my imageview,
but in debug mode i see that app execute the line :
startActivityForResult(i,camdata);
bring me to the cam window and after i get pic it ask me to save the pic and i save it.
after that noting happen – i mean i dont reach the line onActivityResult(int requestCode, int resultCode, Intent data).
why?
the code:

package com.thenewboston.elyakim;

import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

public class Cam extends Activity implements OnClickListener{

    ImageButton ib;
    Button b;
    ImageView iv;
    Intent i;
    final static int camdata = 0;
    Bitmap bmp ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.photo);
        initialize();
        InputStream is1 = getResources().openRawResource(R.drawable.ic_launcher);
        bmp = BitmapFactory.decodeStream(is1);

    }
    private void initialize() {
        // TODO Auto-generated method stub
        iv = (ImageView) findViewById(R.id.imageView1);
        ib = (ImageButton) findViewById(R.id.imageButton1);
        b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(this);
        ib.setOnClickListener(this);
    }
    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        switch (arg0.getId()){
        case R.id.button1:
            try {
                getApplicationContext().setWallpaper(bmp);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            break;

        case R.id.imageButton1:
            i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i,camdata);
            break;

        }

        }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode==RESULT_OK){
            Bundle extras = data.getExtras();
            bmp  = (Bitmap) extras.get("data");
            iv.setImageBitmap(bmp);
        }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:13:08+00:00Added an answer on June 4, 2026 at 9:13 pm
    if(requestCode==RESULT_OK){
            Bundle extras = data.getExtras();
            bmp  = (Bitmap) extras.get("data");
            iv.setImageBitmap(bmp);
        }
    

    must be

    if(requestCode==camdata){
        if(resultCode==RESULT_OK){
            iv.setImageUri(Uri.parse(data.getDataString()));
        }
    }
    

    the above displays the selected image in the imageview

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a groceries list app to learn android, but I cannot
Well, I am beginner in Android and java, but I'm trying to learn. My
I am trying to learn Android app development and wrote a very simple app
i am developing an android todo list app to learn. right now in my
I am a Java beginner , I want to develop Android app , what
I am trying to learn android app development .I am using IntelliJ Idea 10.When
I'm writing a toy car-navigation app for Android, mostly to learn the Android SDK.
I am beginner of Android OpenGL I want to learn and make Live wallpaper
I am trying to read Android source code to learn about binder, but I
I'm writing a puzzle game to learn developing Android Apps. But now I'm stuck

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.