Reputation: 53600
I am using gradient as background in my activity. on some android devices it doesn't look as good and smooth as in Photoshop, to fix this issue somebody told me use onAttachedToWindow()
method.
I checked Android page (http://developer.android.com/reference/android/app/Activity.html#onAttachedToWindow()) and I found that this method is a part of android.app.Activity
and I wrote following lines of code:
package com.test.test1;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Window;
public class Mainctivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
}
but when run the emulator, it crashed and in DDMS I saw this error:
11-25 10:48:13.353: E/dalvikvm(216): Could not find method android.app.Activity.onAttachedToWindow, referenced from method com.test.test1.MainActivity.onAttachedToWindow
What is my fault?
Upvotes: 2
Views: 6618
Reputation: 200
This method is available since API Level 5. What version of Android is running on the emulator?
Upvotes: 3
Reputation: 33792
As per the comments above, I've had this code tested on an actual device and it worked smoothly. So this is an emulator problem. Hopefully this will be resolved in later versions of the sdk.
Upvotes: 2