changing system wallpaper

by Bam » Sat, 14 Mar 2009 02:11:12 GMT


Sponsored Links
 ello guys,
i have a problem. when i select an image from an
image switcher , i want to set this selected image as the background
of my application when i click on a button .. how can i do this.. here
is a sample of my codes.

thanxs in Advance.
----------------------------------------------------------------------

package com.androwall;

import java.util.ArrayList;

import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ViewSwitcher;
import android.widget.Gallery.LayoutParams;


public class androwall extends Activity implements
ViewSwitcher.ViewFactory, AdapterView.OnItemSelectedListener {

/** Called when the activity is first created. */

private int mCurrentSelectedImage;
private TextView mTVCurrentWallpaper;
private Boolean bool = true;

private ArrayList<Drawable> allimages = new ArrayList<Drawable>
();

@Override
public void onCreate(Bundle icicle)

{
super.onCreate(icicle);

requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView
(R.layout.main);

for (int i = 0; i < mImageIds.length; i++)
{
allimages.add(this.getResources().getDrawable(mImageIds
[i]));
}


mSwitcher = (ImageSwitcher) findViewById(R.id.switcher);
mSwitcher.setFactory(this);
mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));

Gallery gallery = (Gallery) findViewById(R.id.gallery);
gallery.setAdapter(new ImageAdapter(this));

gallery.setOnItemSelectedListener(this);

final Button btnSetWallpaper = (Button) findViewById
(R.id.btnsetwallpaper);
btnSetWallpaper.setOnClickListener
(btnSetWallpaperListener);


}//end of onCreate


//when clicked on button set as wallpaper
private Button.OnClickListener btnSetWallpaperListener = new
Button.OnClickListener()
{
public void onClick(View v)
{
NotificationManager nm = (NotificationManager)
getSystemService(NOTIFICATION_SERVICE);
try
{


Bitmap newwallpaper = Bitmap.createBitmap
(newwallpaper, 320, 240, mCurrentSelectedImage, mCurrentSelectedImage,
null, true);



Canvas myCanvas = new Canvas(newwallpaper);
allimages.get(mCurrentSelectedImage).draw
(myCanvas);
setWallpaper(newwallpaper);



broadcastIntent (new Intent
(Intent.ACTION_WALLPAPER_CHANGED)); //added by arvish for test

}
catch (Exception e)



Other Threads

1. Include .jar file in my project?

If I have a .jar file that contains libraries that I want to
use in my android application, how can I make them available
to my main code?

Thanks,

Toby

--

2. disable log messages "dataCallback(16, 0x11af10)" when using mCamera.setPreviewCallback(this);

Im using Camera.setPreviewCallback method to retrieve all the camera
frames on the onPreviewFrame on a 2.0.1 device.
Im aware about the issue of GC interrupting on each frame on < 2.2
platforms (http://code.google.com/p/android/issues/detail?id=2794) and
I'm using the suggested work-around.
However, there is also a log message "dataCallback(16, 0x11af10)"
being print on logcat on each frame like this:
...
D/Camera-JNI( 1795): dataCallback(16, 0x11af10)
D/Camera-JNI( 1795): dataCallback(16, 0x11af10)
D/Camera-JNI( 1795): dataCallback(16, 0x11af10)
D/Camera-JNI( 1795): dataCallback(16, 0x11af10)
...

These messages are very annoying because they make it harder to find
my other log messages among them.
My question is:
Is it possible to disable the dataCallback(16, 0x11af10) log messages?

-- 

3. Dex not working with spaces in path on the new android platform tools (V8)

4. Can not find target after updating android 2.3 sdk

5. who can give me android 2.2 system source code ?

6. Bring the app to foreground

7. Maximum number of touch events Android can handle