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);
Related
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).
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!
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)
Upon writing a simple Android application in Qt, I encountered an uncomfortable dilemma:
I have a subclass of QWidget called PlotView, and have reimplemented the event-function from it:
bool PlotView::event(QEvent *event){
if(event->type() == QEvent::Gesture){
emit gestureEvent(static_cast<QGestureEvent*>(event));
return true;
}
return QWidget::event(event); \\Line A
}
Also I have the following lines in the class constructor:
this->grabGesture(Qt::SwipeGesture);
this->grabGesture(Qt::PanGesture);
this->grabGesture(Qt::PinchGesture);
this->setAttribute(Qt::WA_AcceptTouchEvents);
What I find very peculiar is that when running the application like this, it does not recognize any gestures. However, when removing the last line of the function (Line A above), the gestures are suddenly recognized, but the widget is not painted.
Some specs: I am currently running Qt 5.2.0, compiling on a Samsung Galaxy Note 10.1 GT-N8010 running Android 4.1.2.
Does anyone have any suggestions to how I could make this run with both the widget being painted and gesture recognition?
It seems adding the lines
this->grabGesture(Qt::SwipeGesture);
this->grabGesture(Qt::PanGesture);
this->grabGesture(Qt::PinchGesture);
this->setAttribute(Qt::WA_AcceptTouchEvents);
to the parent class constructor fixed the problem.
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.