Java Question some puzzleds with develop library

icefairy333

Active Member
Licensed User
Longtime User
1,somewhere I had to access with sharedProcessBA,for example I want to change the attribs of window,when I use BA,the code will cause many kinds of error,then I use jd-gui to saw the core.jar I found that you call the sharedProcessBA,so I copy the code to my lib it works.
2,yesterday I new a object of linearlayout then call ba.activity.addcontentview to pass the object,compile ok,when call it in b4a the b4a get a NullPointerExecption
:(
 

icefairy333

Active Member
Licensed User
Longtime User
this code worked ok!
B4X:
public void ShowBanner(int x,int y,int width,int height,int gravity,int refushsecond){
   WeakReference w = ba.sharedProcessBA.activityBA;
     Activity act1=((BA)w.get()).activity;
   LinearLayout container =new LinearLayout(act1);
   LayoutParams lp1=new LayoutParams();
   lp1.x=x;
   lp1.y=y;
   lp1.height=height;
   lp1.width=width;
   lp1.gravity=gravity;
   UUAppConnect.getInstance(ba.context).showBanner(container , refushsecond);
   act1.addContentView(container, lp1);
}
but this one cause a NullPointException:
B4X:
public void ShowBanner(int x,int y,int width,int height,int gravity,int refushsecond){
   LinearLayout container =new LinearLayout(act1);
   LayoutParams lp1=new LayoutParams();
   lp1.x=x;
   lp1.y=y;
   lp1.height=height;
   lp1.width=width;
   lp1.gravity=gravity;
   UUAppConnect.getInstance(ba.context).showBanner(container , refushsecond);
   ba.activity.addContentView(container, lp1);
}
 
Top