以下应用程序按预期工作:
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
末尾插入 a ,似乎不会被调用:壁纸不会更改为 foo.jpg。画廊第二次启动时是否被调用?到底是怎么回事?onStart()
onActivityResult()
onActivityResult()