0

Right I've looked at a shed load of tutorials, questions and so on but none have worked, so I don't need more links, I just need a fix for my current code..

So far I have this:

public class FullscreenActivity extends Activity {



protected int[] mThumbIds;

@SuppressWarnings("unused")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fullscreen);

    // get intent data
    Intent i = getIntent();

    // Selected image id
    final int position = i.getExtras().getInt("id");
    ImageAdapter imageAdapter = new ImageAdapter(this);

    ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
    Button SetWallpaper = (Button)findViewById(R.id.setwallpaper);
    imageView.setImageResource(imageAdapter.mThumbIds[position]);

}
        private Object[] imageIDs;
        private int position;


        public void onClick(View arg0) {

        try {
            WallpaperManager.getInstance(this).setResource((Integer) imageIDs[position]);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        }
     }

But when I click the button once the picture has been selected, it doesn't do anything?

I also have the permission in the manifest but it still doesn't work, so any help would be hugely appreciated

Thank you

I'm not sure if this has anything to do with it or not but I'm testing the app on a Samsung Galaxy S4

SkintMedia
  • 33
  • 1
  • 5

1 Answers1

0

May be it can relate..

package com.Engr.android;

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.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

public class Camera extends Activity implements View.OnClickListener
{   
    ImageButton ib;
    ImageView iv;
    Button btn;
    Intent i;
    final static int cameraData = 0;
    Bitmap bmp;

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

    private void Buttons()
    {
        ib = (ImageButton) findViewById(R.id.ibtnTakePic);
        iv = (ImageView) findViewById(R.id.ivReturnPic);
        btn = (Button) findViewById(R.id.btnSetWall);
        btn.setOnClickListener(this);
        ib.setOnClickListener(this);
    }

    @SuppressWarnings("deprecation")
    @Override
    public void onClick(View v) {
        switch(v.getId())
        {
        case R.id.btnSetWall:
            try {
                getApplicationContext().setWallpaper(bmp);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            break;
        case R.id.ibtnTakePic:
            i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i, cameraData);
            break;
        }
    }

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

}