0

Here are the values I want to get in another class.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(new RealPlayView(this));
    super.onCreate(savedInstanceState);
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int width = dm.widthPixels;
    int height = dm.heightPixels;
}

In my class I want to get the width and height but so far I haven't been able to.

Any tips?

I've tried putting the DisplayMetrics into difference methods and then trying to call those methods in my other class but its giving me errors.

Is there any way I can get these values into my class?

Sufian
  • 6,405
  • 16
  • 66
  • 120
user1012016
  • 79
  • 1
  • 1
  • 5

1 Answers1

0

You can use your data from one activity in some other activity in many ways:

If you want to use data from one activity immediately in some other activity then you can use Intents for that.Here is an example for it How to pass an object from one activity to another on Android and for more information you can refer to http://developer.android.com/guide/topics/intents/intents-filters.html

You can also store data from one activity in some files and then read from them in other activity. Here is all you need to know about Data Storage http://developer.android.com/guide/topics/data/data-storage.html

Community
  • 1
  • 1
dark_shadow
  • 3,503
  • 11
  • 56
  • 81