0

i am creating a simple wallpaper app in which i have a image_view and a button.

image-view is showing a image, now what i want: i want to open image with wallpaper app on button click.

when i click button it should show all installed wallpaper app so i can choose any of them

to better understand see screenshot: this should happen when i click button

enter image description here this is my code:

package com.example.wallpaper_test;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class WallpaperScreenActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.wallpaper_layout);

        // image resource
        ImageView img = (ImageView) findViewById(R.id.imageView1);
        img.setImageResource(R.drawable.pop);

        // call installed wallpaper app to set wallpaper on button click
        Button b1 = (Button) findViewById(R.id.button1);
        b1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View vx) {

            }
        });

    }
}
user3739970
  • 591
  • 2
  • 13
  • 28

1 Answers1

0

This question has been answered here

    Uri uri = Uri.parse("URI_OF_YOUR_IMAGE");

    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(uri, "image/jpeg");
    intent.putExtra("mimeType", "image/jpeg");
    this.startActivity(Intent.createChooser(intent, "Set as:"));
Community
  • 1
  • 1
BrainCrash
  • 12,992
  • 3
  • 32
  • 38
  • i am getting error with `REQUEST_CODE`, `Description Resource Path Location Type Syntax error on token ",", Expression expected after this token WallpaperScreenActivity.java /Wallpaper_Test/src/com/example/wallpaper_test line 43 Java Problem ` – user3739970 Jul 26 '14 at 11:56
  • You have to provide your own REQUEST_CODE as a int check the [startActivityForResult](http://developer.android.com/reference/android/app/Activity.html#startActivityForResult) documentation. – BrainCrash Jul 26 '14 at 15:10
  • i am not understanding will you please give me some code help – user3739970 Jul 26 '14 at 16:54
  • bro i used your this code `Intent intent = new Intent(); intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); startActivityForResult(intent, REQUEST_CODE);` it takes me to live_wallpapers. please see my whole question . my question is not how to go to live wallpaper, instead my question is how do i open image with wallpaper app see provided screenshot – user3739970 Jul 26 '14 at 18:55