如何在android中将数据从activity传递到class?

How to pass data from activity to class in android?

如何将数据从 activity 传递到 class。 ?
我的锁屏 class 如下所述。我想将数据从 activity 传递到此锁定屏幕 class。

有人帮帮我吗?

Lock Screen class
*****************

public class LockScreen extends Activity{

public WindowManager winManager;
public RelativeLayout wrapperView;

public int background;


@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    }

主要Activity


  public static int   backgroundPics;        
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

    }

My problem is I didn't get the updated value of background in Lockscreen class. It is always shows 0. 
Create a class for your requirement as CustomView and define public method to pass integer value and use it there. As I have created setIntValue().

    public class CustomView extends View {
    private int mIntValue;

    public CustomView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public CustomView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomView(Context context) {
        super(context);
    }

    public void setIntValue(int value) {
        //Like this you can use this integer value
        //this.mIntValue = value;
        //this.setText(value);
    }
}

用法: 1。直接使用 CustomView class 实例:

CustomView mView = new CustomView(this);
mView.setIntValue(100);

2。在布局中使用 CustomView xml:

在你的布局中xml-

<your_app_package_for_custom_view_class.CustomView
        android:id="@+id/customview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

在你的Activity-

CustomView mView = (CustomView)findViewById(R.id.customview);
mView.setIntValue(100);