krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
05/06/18 06:24 AM (6 years ago)

Android - getScreenDataByItemNickname

Hi All I'm updating an old android app into the latest BT app format. Previously, I have done quite a lot customization of code and unfortunately some of this customization isn't sitting well with the latest BT version. For instance, previously I used the following code to open the 'Settings' screen from the 'Settings' button, making use of the getScreenDataByItemNickname to obtain the screen data from the BT_config file: // setup click handler for settings button btn_settings.setOnClickListener(new OnClickListener() { public void onClick(View v) { BT_item tapScreenLoadObject = appname_appDelegate.rootApp.getScreenDataByItemNickname("Settings"); loadScreenObject(null, tapScreenLoadObject); BT_debugger.showIt(fragmentName + ": settings"); } }); Unfortunately, with the latest BT app package, the getScreenDataByItemNickname is deprecated and I'm getting the following: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.appname.data_models.BT_item.getItemType()' on a null object reference at the following line in BT_fragment: //type of screen to load next... String nextScreenType = theScreenData.getItemType(); Any help much appreciated. Regards, krompa
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
05/06/18 10:10 AM (6 years ago)
What I'm not convinced about is that the following useful code really is deprecated: getScreenDataByItemNickname getScreenDataByItemId ... because this code appears in a number of the 'core' plugins (e.g. Menu List Simple and Menu Buttons as well as BT_fragment.java and other files. Given it is code written by BT, I don't think that it is deprecated. But it is appearing with a line through it and labelled as deprecated in (my) Android Studio. Can others confirm if this is the case in any recently downloaded Android app?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
05/08/18 09:37 PM (6 years ago)
I haven't actually looked at the code, but I suspect that the 'method' is not deprecated; those are custom methods that David wrote. However, the core code that make up those methods may need an update. I haven't messed with Android for a bit, but I'll try and take time to drag a project out and take a look. Cheers! -- Smug
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
05/09/18 02:56 AM (6 years ago)
Thanks Smug See Android Studio screenshot of a custom plugin, but the same is true in the untouched BT core plugins ... https://www.dropbox.com/s/h6rb2bqjguu16t6/getScreenDataByItemNickname.png?dl=0 When I run the app, it crashes because there is no returned value for getScreenDataByItemNickname I agree with you that the method is probably not deprecated. But it would be good to see a fix as it is one of the most useful methods in BT.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.