views:

16

answers:

0

Hi,

I'm trying to get my widget button (or the Widget itself) position to pass it to another activity triggered by this button. I've tried like this at the other activity on onCreate() method, and NPE is happening:

Button b1 = (Button) findViewById(R.id.ButtonLogin);        
int[] outLocs;
if (b1.getWindowToken() == null)
      outLocs = null;
else {
      outLocs = new int[2];
      b1.getLocationOnScreen(outLocs);
}

I've also tried unsuccessfully (NPE) doing at my Widget update class (extends service) also at onUpdate() method, using the intent that triggers the other activity:

Intent configIntent = new Intent(context, ClickOneActivity.class);
Rect outLocs = configIntent.getSourceBounds();
Log.d(VexWidget.LOG_TAG, "x=" + outLocs.flattenToString() + "\n");
Log.d(VexWidget.LOG_TAG, "y=" + outLocs.centerY());

I've heard it's not possible call such positions method at any construct/update methods at App lifecycle.

But what should I have to do for achieve what I want? (the position on the screen of my widget being seen by other activities).

Thanks a lot.