Google Play Services with openGL and BaseGameUtils - android

I'm trying to implement achievements with Google Play Services in a game. I have followed up the steps in this documentation and everything is ok except I got a runtime warning and then a crush. The warning is:
06-09 10:43:05.900: W/PopupManager(17888): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.
My application is using openGL and the activity has a member mView that extends GLSurfaceView.
I have tried this and this (I have all those meta tags and the app_id setup correctly).
Also, TypeANumber starts correctly with my app_id.
Can anyone help me on this?
EDIT [added some code]:
Here is the Activity declaration:
public class GGActivity extends BaseGameActivity implements SensorEventListener, IDownloaderClient {
Here is onCreate where the problem occurs (after the change suggested by free3dom):
public GGView mView;
#Override protected void onCreate(Bundle icicle) {
setRequestedClients(BaseGameActivity.CLIENT_GAMES | BaseGameActivity.CLIENT_APPSTATE);
//if (DEBUG_BUILD)
{
enableDebugLog(true);
}
setContentView(mView); // make sure mView is created before
getGameHelper().createApiClientBuilder();
getGameHelper().getApiBuilder().setViewForPopups( mView );
super.onCreate(icicle);
YES, setContentView helped. Thanks!

In order for your activity to recognize and use the GLSurfaceView you have to set it. This can be done by calling
setContentView(mView);
after creating the GLSurfaceView (documentation can be found here).

Related

React native draggable flatlist not draggable

I tried implementing react-native-draggable-flatlist to my project, but I'm not able to drag the elements. I am able to "pick them" (They get bigger if I press them), but I can't move them to another position.
I had this problem before and found a working soloution in a GitHub issue, but as it seems, MainActivity.java has changed in some version and I don't know how to correctly upgrade it.
The soloution I found:
When I add the #Override for the ReactActivityDelegate, my App crashes after the build.
I noticed that my MainActivity.java looks a little bit different, it seems like the ActivityDelegate is Managed through a class called MainActivityDelegate which extends ReactActivityDelegate:
public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}
#Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
}
It seems like I have to change something here to achieve the same result, but I don't really know what.
EDIT:
According to the RNGH docs you shouldn't change your MainActivity.java that way anymore and wrap your whole App into a GestureHandlerRootView. Some Libaries like react-native-navigation do this by default (in my case). BEcause of that (I think) my App gets completely grey when I use a GestureHandlerRootView. If I don't addd it myself, so I use the one from neavigaion, I still can't drag the items in my list.
I fixed it by wrapping my screen component in a GestureHandlerRootView

Trouble instantiating gdx-pay purchaseManager in my game

I am trying to set up gdx-pay in my game. I have followed the official readme (https://github.com/libgdx/gdx-pay/), but can't seem to instantiate the PurchaseManager in my AndroidLauncher.
I have set up a class that handles PurchaseManager installation, but every time I try to instantiate it in the AndroidLauncher I get this error:
"java.lang.RuntimeException: Unable to start activity ComponentInfo{appPackage.AndroidLauncher}: java.lang.IllegalArgumentException: Support for pending purchases must be enabled. Enable this by calling 'enablePendingPurchases()' on BillingClientBuilder."
The readme says to add this to the AndroidLauncher onCreate
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
The problem is that I have to add this
ProjectName.purchaseManager = new PurchaseManagerGoogleBilling(this);
This give me an error saying that I have to make purchaseManager static in my ProjectName class
When I do this, I get the RuntimeException mentioned above.
The sample gdx-pay project instantiates PurchaseManager with this code
public class AndroidLauncher extends GenericAndroidLauncher {
#Override
protected void initFlavor(GdxPayApp game) {
super.initFlavor(game);
game.purchaseManager = new PurchaseManagerGoogleBilling(this);
}
}
When I try this, #Override is invalid and initFlavor does not exist. I tried looking for initFlavor in the gdx-pay files, but had no luck finding anything...
Thanks for taking the time to help
Well it turns out that the following line in my android gradle was the issue
implementation 'com.android.billingclient:billing:2.0.1'
Gdx-pay takes care of this automatically and uses client 1.1
Setting the billingclient to 2.0.1 was the problem. I was able to fix it by deleting that line. Big thanks to the libGdx discord guys!

How to load a specific layout of an activity in android

I am working on an augment reality android app. I developed the app in unity using vuforia and then imported it in android studio as i wanted to design it in android studio. The activity name in generated project structure is UnityPlayerActivity which has no layout in the project. The activity is passed to UnityPlayerclass and the layout is generated. This is some code of my UnityPlayerActivity activity.
protected UnityPlayer mUnityPlayer; // don't change the name of this variable; referenced from native code
// Setup activity layout
#Override protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
getWindow().setFormat(PixelFormat.RGBX_8888); // <--- This makes xperia play happy
mUnityPlayer = new UnityPlayer(this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
}
as it uses that layout how can i design that activity by referencing it.
It is not possible to do this by referencing the object(Java does not support call by reference).
You need to define a new function in UnityPlayer class that generates a layout and returns the LayoutParams object.
Then use the Layout inflator. Something like this:
LayoutParams mParams=mUnityPlayer.layoutGenerator() //some function to generate LayoutParams
LayoutInflator.getLayoutInflator().inflate(LayoutParams);
Finally i found an easy solution to my problem. I displayed the unity scenes in a subview using a framelayout and now i can customize the UI easily. Check here and here to see more information.

Red lines in Android Studio with Ampiri

I have used Ampiri integration in my app.
I copy paste all the code from their android sdk integration wizard for banner ads into my code. What bothers me is that Android Studio can not find that listener and view in the red letter.
So what is that I miss? Is there any problems on my code? If not what should I do to resolve this issue? Please help me.
Following is my code:
I’ve implemented the AdEventCallback using:
import com.ampiri.sdk.listeners.AdEventCallback;
and call it from main activity inside onCreate as describe in my code below:
public abstract class MainActivity extends AdCallbackActivity implements AdEventCallback {...}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FrameLayout adView = (FrameLayout)view.findViewById(R.id.ad_view);
StandardAd standardAd = new StandardAd(this, adView,“MY_ADUNIT_ID",BannerSize.BANNER_SIZE_320x50, adListener);
standardAd.loadAd();
Please check my comments inline for each error.
view.findViewById(R.id.ad_view)
If the ad_view is in the current Activity layout set by setContentView, you don't need to add "view."
i.e.
findViewById(R.id.ad_view)
adListener
Please implement an event listener interface AdEventCallback, referencing to our integration page.
In addition, If you will have the AdEventCallback methods in your AdCallbackActivity.java file.
please try the code below.
StandardAd standardAd = new StandardAd(
this, adView, "3dfbb889-3bcd-4c34-82ae-8fcb539c3b25",
BannerSize.BANNER_SIZE_320x50, this);
If it doesn't work, please send me your MainActivity and AdCallbackActivity to suppport#ampiri.com.

Android - How to close or hide a view and bring it back

I have three views in my app and I would like to be able to hide them and bring them back selectively. I have tried using the following triggered by a button click event:
if(SurfaceView().isShown()==true){
SurfaceView().setVisibility(View.INVISIBLE);
}else if(!SurfaceView().isShown()){
SurfaceView().setVisibility(View.VISIBLE);
}
However this usually freezes up the views and then closes the app with no errors except the following :
NvRmChannelSubmitt: NvError_IoctlFailed with error code 14
EDIT: the view that Im referring to is actually the _glsurfaceview in the renderactivity from min3d
public class RendererActivity extends Activity implements ISceneController
{
public Scene scene;
protected static GLSurfaceView _glSurfaceView;
My main activity extend RenderActivity
EDIT: added logcat dump
The only things showing up upon the closing are these
03-02 15:57:00.338: I/Min3D(28364): Renderer.onSurfaceChanged()
03-02 15:57:00.355: D/(28364): NvRmChannelSubmit: NvError_IoctlFailed with error code 14
Looks like you might have a copy/paste typo in your code. Are you trying to show the glSurfaceView if the SurfaceView is invisible? If so, try this:
if( SurfaceView().isShown() )
{
glSurfaceView().setVisibility(View.GONE);
}
else if ( !SurfaceView().isShown() )
{
glSurfaceView().setVisibility(View.VISIBLE);
}
So I fixed my problem. I think when your using opengl and glsurfaceviews you have to change what I have above to the following:
if(glSurfaceView().isShown()==true){
SurfaceView().onPause();<----------------------added to pause view
SurfaceView().setVisibility(View.GONE);
}else if(!glSurfaceView().isShown()){
SurfaceView().onResume();<---------------------added to resume view
SurfaceView().setVisibility(View.VISIBLE);
}
The SurfaceView().onPause() tells the glsurfaceview that I want the renderer to pause and vice versa for onResume().
Now Im not sure this is the end all fix for this situation but it is working for like this.
Using View.GONE will make the view invisible, and will not take up any space in your layout.

Categories

Resources