I am creating app to set image as wallpaper. I am using following code to fix image in every screen. The code is working fine. Image fit properly. But I have one problem if I play any game and then back to home screen or I restart my device then size of wallpaper zoom. I want to stop this. I want image size fit as it is on first time when I set wallpaper from my android app.
Here's Code-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.full_image);
face = Typeface.createFromAsset(getAssets(), "fonts/ABEAKRG.TTF");
Intent i = getIntent();
position = i.getExtras().getInt("id");
full = (LinearLayout) findViewById(R.id.full);
btn = (Button)findViewById(R.id.btn);
btn.setTypeface(face);
btn.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Bitmap tempbitMap = BitmapFactory.decodeResource(getResources(), mThumbId[position]);
Bitmap bitmap = Bitmap.createScaledBitmap(tempbitMap,width,height, true);
WallpaperManager wallpaperManager = WallpaperManager.getInstance(FullImageActivity.this);
wallpaperManager.setWallpaperOffsetSteps(1, 1);
wallpaperManager.suggestDesiredDimensions(width, height);
try {
wallpaperManager.setBitmap(bitmap);
Toast.makeText(getApplicationContext(), "Done", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
e.printStackTrace();
}
}});
changeBackground();
ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this);
full.setOnTouchListener(activitySwipeDetector);
}
private void changeBackground(){
full.setBackgroundResource(mThumbId[position]);
}
Thanks in advance.