0
- 显示s JPEG图像。
- 在图像上显示一个按钮,允许用户将图像设置为墙纸。
- 将图像自动调整为用户特定的Android手机显示尺寸。
- 卸载应用程序后移除壁纸。
我可以做第1步和第2步很容易我只是坚持其他两个步骤任何人都可以指向正确的方向。 这里是到目前为止的代码我需要此项目的建议
public class MainActivity extends Activity implements OnClickListener {
ImageView iv;
Button b;
Intent i;
Bitmap bmp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initialize();
InputStream is = getResources().openRawResource(R.drawable.image);
bmp = BitmapFactory.decodeStream(is);
}
private void initialize(){
iv = (ImageView) findViewById(R.id.ivReturnedPic);
b = (Button) findViewById(R.id.bSetWallpaper);
b.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.bSetWallpaper:
try {
getApplicationContext().setWallpaper(bmp);
} catch (IOException e) {
e.printStackTrace();
}
break;
}
}
}
你的问题是什么? – Pragnani 2013-04-09 16:54:41
'如果应用程序已卸载,则删除墙纸.'这是不可能的,您的应用程序在卸载时不会收到回调,因此您当时不能执行任何代码。 – FoamyGuy 2013-04-09 17:09:44