White bitmap in android

I want to set home wallpaper with white bitmap:

    Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(bitmap);

    WallpaperManager wall = WallpaperManager.getInstance(this);
    try {
    } catch (IOException e) {

And the wallpaper becomes black. What’s wrong is here?


My first guess would be your color choice, assuming this is the value in your actual code and not edited.

Color ints in java take the form ARGB, so Color.WHITE is 0xFFFFFFFF, Color.BLUE is 0xFF0000FF, etc.

The color in your code (0xFFF) would expand to 0x00000FFF which is Blue with a little green mixed in, but the alpha channel is zero, so the Canvas is basically written with a transparent color.

If you are using standard colors, I would stick to the constants in the Color class as parameters here, but if you want to define the color yourself, remember to place the full color or use Canvas.drawRGB() instead.


How to architect push notifications to a Swing client from JAX-WS on GlassFish?

I have a widely distributed java swing application that is a web service client from a JAX WebService EJB on a Glassfish 3.1.2 server.

I want to be able to distribute a String notification to all users that stays active until they have read it. The notifications only need to exist within the Swing client.

I have created a superuser web portal to enter the String data and save it to a database.

My question is:

  1. What is the best technology to (push)distribute this data String Notification to my clients?
  2. How should I arcitect the database to know if the notification has been viewed? (So I can stop showing the “New Notification” on the client)

Or if there is a reference to a guide that would work wonderfully, I couldn’t find one.

My Ideas:

  • Have the client call a webservice every 10 minutes to check if there are any new notifications
  • For the database create a notification table and notifications seen. Link my users table to notifications seen table. Notifications seen is very basic with just 3 columns: NotificationID, UserID, TimeSeen.


One way of simulating push notifications is long polling. This technique is called Comet or Reverse AJAX. While it’s more common in REST based services, it can be just as easily accomplished in JAX-WS.

For JAX-WS you will want to investigate:

Have the client call a webservice every 10 minutes to check if there are any new notifications

Instead with long polling, you make the initial client connection right away. But instead of the server responding immediately, it hangs onto the connection (asynchronously). Then when a notification needs to be pushed, it responds back on the existing connection.

With this technique, as soon as information is available on the server, it will be “pushed” to the client.

For the database create a notification table and notifications seen. Link my users table to notifications seen table. Notifications seen is very basic with just 3 columns: NotificationID, UserID, TimeSeen.

Sounds good. Expose it as a JAX-WS service. When the client receives the message, have them invoke it with the NotificationID.

Something like:

NotificationService svc = ...;
UserId userId = ...;

AsyncHandler<Notification> handler = new AsyncHandler<Notification>()
    public void handleResponse (Response<Notification> response)
       Notification notification = response.get();

       // update swing gui

       NotificationID notificationId = notifcation.getId();

       svc.markNotificationAsSeen(userId, notificationId);

       // continue polling forever (or put in some logic to stop)
       svc.getNotificationAsync(userId, this);

Future<?> invocation = svc.getNotificationAsync(userId, handler);

Exit animation not working; FragmentTransaction custom animation does not work for hide

I use show/hide to display a fragment that takes up part of the screen. For some reason when the fragment is shown the slide_in_left animation plays, but when the fragment is being hidden there is no animation, the fragment just disappears. I’ve tried using the slide_in_left animation for both exit and enter, this did not help. When a trace the code into the support package, the animation does get created and the code for displaying it is being executed. (I traced the .hide call)

FragmentManager fm = _activity.getSupportFragmentManager();
Fragment fragment = fm.findFragmentById(;
FragmentTransaction ft = fm.beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left);
if (fragment.isHidden()) {;
} else {

Just in case here’s the xml for the slide_out_left animation

<set xmlns:android="">
    <translate android:fromXDelta="0" android:toXDelta="-50%p"
    <alpha android:fromAlpha="1.0" android:toAlpha="0.0"
        android:duration="@android:integer/config_mediumAnimTime" />

Edit: It’s possible that the problem has something to do with the fact that my_fragment shares screen width with another fragment cotaining a webview. When .show is executed for my_fragment it becomes visible and shares space within a horizontal linear layout (how much screen width each of the two fragments takes up is determined by the weight parameter).


Personally for me this is a bug with the zPosition for Fragment animations.

What you see is the new fragment “appearing” this is because the new fragment is attached underneath the current one.

So when trying to animate a fragment ‘Over the top’ of an existing fragment, it appears like nothing is happening then the new one just ‘appears’.

I have tried many work arounds, playing with zPosition (only affects windows not layouts, so no effect to fragments), onAnimationCreate() bringing the root layout to front or even on animation start and stop… seems to do nothing.

So at this point in time without writing a complete custom animation for fragment transitions, they are a bit buggy at the moment.

You may have to play with. .add(Fragment) wait for it to be added, then call .remove(Fragment) removing the old fragment, that way the new fragment is physically placed on top of the existing fragment.


Android Emulator: Installation error: INSTALL_FAILED_VERSION_DOWNGRADE

I am currently trying to compile and test a small Android Application.

I am using Eclipse, and have SDK 4.2 (Api Level 17) installed. I’ve set

<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="8" />

although I’ve tried also different values (i.e. 17/17).

I do not use any GoogleAPI functions, nor do I use functions that are not available in API Level 8. Or at least I do not get any compile errors or warnings in that regard.

When I compile the project and run it on a real device running Android 2.2.1 the Application runs fine. However when I try to run the application on an emulator (Android Virtual Device) with Android 4.2, Api Level 17 I get the following error:

[2012-12-10 21:10:29 - SoftKeyboard] Installation error: INSTALL_FAILED_VERSION_DOWNGRADE
[2012-12-10 21:10:29 - SoftKeyboard] Please check logcat output for more details.
[2012-12-10 21:10:29 - SoftKeyboard] Launch canceled!

Logcat however is empty. I have really no clue, what this error even means…


It means you’re trying to install an app with the same packageName as an app that’s already installed on the emulator, but the one you’re trying to install has a lower versionCode (integer value for your version number).

You might have installed from a separate copy of the code where the version number was higher than the copy you’re working with right now. In either case, either:

  • uninstall the currently installed copy

  • or open up your phone’s Settings > Application Manager to determine the version number for the installed app, and increment your <manifest android:versionCode to be higher in the AndroidManifest.

  • or


Which browsers support multi-line strings?

Which browsers support multi-line strings?


As usual, my main suspect for not supporting it is IE. Which IE version is the first that supports it?


All current versions of the major browsers accept multi-line strings.

Note: this technique is apparently not in compliance with browser standards; however, it works out fine when tested across all current versions of the major browsers.

  • Some online tools such as JSLint don’t allow it
  • Multi-line strings can be dangerous in JavaScript because all hell breaks loose if you accidentally put a whitespace in between the escape character () and a new line. (@ripper234 comment)

Multiline String literals are disallowed by the Google Style Guide.

Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..