次のアプリケーションは期待どおりに機能します。
import android.app.Activity
import android.content.Intent
import android.graphics.BitmapFactory
import android.app.WallpaperManager
class ChwallActivity < Activity
def onCreate(state)
super
setContentView R.layout.main
end
$Override
def onStart
super
Intent intent = Intent.new(Intent.ACTION_PICK)
intent.setType "image/*"
startActivityForResult Intent.createChooser(intent, "Select Picture"), 0
end
$Override
def onActivityResult(requestCode, resultCode, data:Intent)
super
thumb = BitmapFactory.decodeFile "/storage/sdcard0/download/foo.jpg"
manager = WallpaperManager.getInstance self
manager.setBitmap thumb
end
end
これにより、ギャラリーピッカーが無限ループで実行されますが、これは望ましくありません。ただし、関数finish
の最後にを挿入すると、呼び出されないようです。壁紙はfoo.jpgに変更されません。ギャラリーが2回目に起動したときに呼び出されますか?何が起こっている?onStart()
onActivityResult()
onActivityResult()