R.drawable.bgimg2应用的是工程drawable中的资源,这是android的一个资源映射,你要现实sd卡中的图片,只能讲图片加载为drawabel然后通过setBackgroundDrawable来实现
/**
 * 生成图片
 * 
 * @param path
 * @return
 */
public static Bitmap creatBitmap(String path) {
if (path == null || path.equals("")) {
return null;
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPurgeable = true;
try {
Bitmap bitmap = BitmapFactory.decodeFile(path);
RocLog.info("ViewUtil", "@@creatBitmap@@ the is bitmap :" + bitmap);
return bitmap;
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
return null;
}setBackgroundDrawable(new BitmapDrawable(creatBitmap(path)));

解决方案 »

  1.   

    两个Activity之间的通信要通过Intent,你可以设置为startActivityForResult,通过返回码来自动设置
    或者用Service和广播都可以实现
      

  2.   

    bttton.setBackgroundDrawable(new BitmapDrawable(BitmapFactory.decodeFile(SD卡路径)));
      

  3.   

    首先这个用不着广播吧。传对象就可以解决。。
    简单写了一个例子。。
    点击btn1实现改背景的效果package com.lxl.testapp;import java.io.IOException;
    import java.io.InputStream;
    import java.util.List;import android.app.Activity;
    import android.app.Notification;
    import android.app.NotificationManager;
    import android.app.PendingIntent;
    import android.content.Context;
    import android.content.Intent;
    import android.content.pm.PackageInfo;
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.ViewGroup.LayoutParams;
    import android.view.WindowManager;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.ImageView;
    import android.widget.RelativeLayout;public class MainActivity extends Activity {
    Context context;
    private NotificationManager mNotificationManager; //通知管理
    int NOTIFICATIONS_ID=111;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.context=this;
    Log.e("TEST", "MainActivity启动");

    setContentView(R.layout.activity_main);
    // ImageView i=new ImageView(this);
    // i.setBackgroundResource(R.drawable.showicon);

    // WindowManager wm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE);
    // wm.addView(i, new WindowManager.LayoutParams(-1,-1));

    List<PackageInfo> packs = context.getPackageManager()
    .getInstalledPackages(0);
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); //初始化管理器

    final RelativeLayout r=(RelativeLayout) findViewById(R.id.layout);


    final WaitDialog waitDialog = new WaitDialog(context);


    Button btn1=(Button)findViewById(R.id.btn1);
    btn1.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    InputStream open=null;
    try {
    open = context.getResources().getAssets().open("showicon.png");
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    Drawable d = Drawable.createFromStream(open, "showicon.png");
    r.setBackground(d);
    }
    });

    Button btn2=(Button)findViewById(R.id.btn2);
    btn2.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    Intent i=new Intent();
    i.setClass(context, MyActivity.class);
    context.startActivity(i);
    }
    });

    Button btn3=(Button)findViewById(R.id.btn3);
    btn3.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
    setWeather("信息", "标题", "内容", R.drawable.showicon);

    }
    });
    }

    @Override
    protected void onDestroy() {
    Log.e("TEST", "MainActivity结束");
    super.onDestroy();
    } private void setWeather(String tickerText, String title, String content,
    int drawable) {
    // 建立一个通知实例,第一个参数是图片,第二个标题栏上显示的文字,第三个是时间
    Notification noti = new Notification(drawable, tickerText,
    System.currentTimeMillis());
    // 当单击下拉下来的标题内容时候做什么,这里是跳转到主界面。这里和下面是一起的。
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
    new Intent(), 0);
    // 设置样式,默认为声音
    noti.defaults = Notification.DEFAULT_SOUND;
    // Title 是拉下来的标题,Content也是下拉后的内容显示
    noti.setLatestEventInfo(this, title, content, contentIntent);
    // 显示这个通知
    mNotificationManager.notify(NOTIFICATIONS_ID, noti);
    }}