0

我想設置圖像在我的Android應用程序的牆紙,有我的代碼:設置壁紙的Android(打開的對話框詢問)

private class SetAsBackground implements View.OnClickListener { 
    @Override 
    public void onClick(View v) { 
     new AsyncTask<Void, Void, Void>() { 
      @Override 
      protected Void doInBackground(Void... params) { 
       Looper.prepare(); 
       try { 
        mShareBitmap = Glide.with(WallPaperDetails.this).load(mImageURL).asBitmap() 
          .into(-1, -1).get(); 
       } catch (final ExecutionException | InterruptedException e) { 
        Log.e("loading_fail", e.getMessage()); 
       } 
       return null; 
      } 

      @Override 
      protected void onPostExecute(Void dummy) { 
       if (null != mShareBitmap) { 
        new ImageSaver(WallPaperDetails.this) 
          .setFileName("wallpaper.png") 
          .setDirectoryName("fine") 
          .save(mShareBitmap); 
        WallpaperManager myWallpaperManager = WallpaperManager 
          .getInstance(WallPaperDetails.this); 
        try { 
         Bitmap bitmap = new ImageSaver(WallPaperDetails.this) 
           .setFileName("wallpaper.png") 
           .setDirectoryName("fine").load(); 
         myWallpaperManager.setBitmap(bitmap); 
         Toast.makeText(WallPaperDetails.this, 
           "Wallpaper successfully changed", Toast.LENGTH_SHORT) 
           .show(); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 
       } 
      } 
     }.execute(); 

    } 
} 

,但我要讓這樣的:

please open it 我怎樣才能做到這一點 ?現在我正在使用圖片保護程序類的壁紙管理器(我可以共享圖像保護程序類的代碼)。在谷歌搜索時,我沒有找到任何其他答案。如果你能解釋一下該應用程序是如何做到這一點,或分享一些代碼...

回答

0
Public void xyz(View v) { 
    Intent intent = new Intent(); 
    intent.setType("image/*"); 
    intent.setAction(Intent.ACTION_GET_CONTENT); 
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), 0); 
} 
+0

什麼是方法視圖V? –