MyCustomWebViewClient undefined - android

I've made a new basic Android app that is just a plain WebView, but, I still managed to get an error to show up in my code:
The constructor AndroidMobileAppSampleActivity.MyCustomWebViewClient(null) is undefined
This is the code in my class:
http://pastebin.com/uEP6BGEV
I've tried to fix this by using a 'quick fix' that eclipse gave me, but then my app wouldn't start up anymore.

Replace:
localWebView.setWebViewClient(new MyCustomWebViewClient(null));
with:
localWebView.setWebViewClient(new MyCustomWebViewClient());
to avoid the need to define a constructor, particularly since you do not appear to be using one.

Related

Android status bar show in Unty

I'm triyng to show the status bar in an Android phone using Unity. I have try this code:
void Start() {
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
But an error appear;
Assets/Scenes/Control/control.cs(15,34): error CS0103: The name 'WindowManager' does not exist in the current context
Does I need to call or import another package? Some could help me with this detail. Thanks in advance.
You cannot use Android Java functions directly in Unity. You can only use whats available in Unity C Sharp. Unity doesn’t understand the method. Suggested workaround, use a ‘Slider’ UI element and manipulate it in a custom c sharp script. Complicated workaround create a custom Unity Plugin which calls the native Android method (possible but complex).

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!

Android - Running my app has an error within super.onCreate

I'm trying to create a simple paint app using the Android Paint module.
When running my app, it gives me an error in "Run", saying that there's a problem at line 14, which is the line which by default is created in my mainActivity:
setContentView(R.layout.activity_main);
None of it is underlined in my code, I can't find any errors at all in my code (including in my activity_main.xml!).
MainActivity.java: https://pastebin.com/zhEbBYdQ
activity_main.xml:https://pastebin.com/jPsA0gMX
CanvasView.java: https://pastebin.com/GctVDz5B
Any ideas? I've tried clean + rebuild, I've tried com.example.R etc.
Full error log: https://pastebin.com/26TebLhy
Thanks in advance. (New to StackOverflow - I have problems putting in code directly to these posts so I hope PasteBin is okay).
CanvasView is in the package evansspeak.paint1, in main_activity however you are trying to inflate it from *com*.evanspeak.Paint1. Fix either one to be the same.
Check that the case matches as well (preferably all lower case)

Simple Gesture App Crashing Android Studio

All Code: https://gist.github.com/anonymous/e11f533921aa4308e29d
I have been following Bucky's "Learn Android Dev". I wrote this code out originally myself, but when it crashed on startup I then copied Bucky's source code. I am using a tablet to run this app, but it crashes on both VM's and the tablet itself with the error
Unfortunately, <app name> has stopped
Any ideas?
To use the GestureDetectorCompat class , you need to create an instance of the GestureDetectorCompat for your View. Refer this documentation.
So the code will fail with null pointer and so you will get ANR at this.gestureDetector.onTouchEvent(event);
So in your onCreate method add following code, should solve your issue.
gestureDetector=new GestureDetectorCompat(this,this);
gestureDetector.setOnDoubleTapListener(this);

android phonegap/cordova change property on webview

In the past, I have changed a normal Webview property on Android. For example:
wv.getSettings().setAllowUniversalAccessFromFileURLs(true);
where wv is a variable of webview. Now, I have an phonegap/cordova app, and I want to change
the same line of code, I have been trying the the following way:
super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
and also like:
super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
I don't get any compiling errors, but when I add that line of code on the onCreate method, the app just closes. I have been trying to add the line on the onCreate method at different places, like, before and after the super.onCreate and before and after loading the html (super.loadUrl("file:///android_asset/www/index.html"), but the app always closes. Any of you know if it is possible to change that property on phonegap/cordova ?
That code is already in our web view so you don't need to set it. Probably the reason it is crashing is that you are not running on an ICS device. That method is only available in ICS or better.
If you really want to add it do:
if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
super.appView.getSettings().setAllowUniversalAccessFromFileURLs(true);
}

Categories

Resources