2014-07-26 29 views
0

我正在創建一個簡單的壁紙應用程序,其中我有一個image_view和一個按鈕。圖像用壁紙打開應用程序

圖像視圖顯示的圖像,現在我想要的:我想打開圖像與按鈕點擊壁紙應用程序。

當我點擊按鈕,它應該顯示所有已安裝的壁紙應用程序,所以我可以選擇任何他們

更好地瞭解見截圖:當我點擊按鈕

enter image description here 這是發生這種情況我的代碼:

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) { 

      } 
     }); 

    } 
} 
+0

是這裏有一個任誰可以幫我 – user3739970

+0

[這可能是使用全到u,但你的形象是不是在現場壁紙列表中顯示,但它設置爲牆紙(HTTP://android-er.blogspot 。在/ 2011/03 /設置牆紙使用,wallpapermanager.html) – user2613464

回答

0

這個問題已經回答了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:")); 
+0

我得到的錯誤與'REQUEST_CODE','說明\t資源\t路徑\t位置\t類型令牌 語法錯誤「」預計在此之後表達令牌\t WallpaperScreenActivity.java \t/Wallpaper_Test/src/com/example/wallpaper_test \t line 43 \t Java問題 ' – user3739970

+0

您必須提供您自己的REQUEST_CODE作爲int檢查[startActivityForResult](http://developer.android.com/reference/android/app/Activity.html#startActivityForResult)文檔。 – BrainCrash

+0

我不是很瞭解你會給我一些代碼幫助 – user3739970