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