I saw a demo of simulateKeyInput,
some codes as following:
final IWindowManager windowManager=IWindowManager.Stub.
asInterface(ServiceManager.getService("window"));
But I can't find ServiceManager in package android.os,
maybe it's not in android SDK, does anyone know where it is?
Looks like a custom implementation of ServiceManager within your project or your projects included .jar files.
Else there is a ServiceManager in javax.jnlp => (Java Network Launching Protocol).. not sure if this is related to you & Android.
android.os.ServiceManager in frameworks/base/core/java/
Related
I am pretty new to Appium, using UIAutomator2. Following instructions on the links:
[https://discuss.appium.io/t/click-back-button-on-android-device-in-java/6817/3][1]
[https://discuss.appium.io/t/click-back-button-twice-in-android-7-using-appium-uiautomator2/20368][2]
[https://stackoverflow.com/questions/30801879/how-to-automate-the-android-phone-back-button-using-appium][3]
I have tried all the options offered in these articles:
driver.pressKeyCode(4);
helper.driver.pressKeyCode(187);
driver.back();
driver.navigate().back();
If I add the imports
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
and I try
driver.pressKeyCode(AndroidKeyCode.BACK);
Eclipse tells me that the method is undefined...
But none of them have worked. Is there anything I need to import or any additional classes I need to create? My driver only has methods for testing, such as close(), equals(), execute(), findElement()... but nothing like back(), or pressKeyCode() or navigate()(this one, probably, because it is not webView)... So, when I try to just type any of those methods, Eclipse either suggests to add a cast, or to create a class...
Please, Can anyone give me some more details on how to do it?
The driver should be an Appium driver. And try to run on real device than emulators.
driver = new AppiumDriver<>(url, desiredCapabilities);
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).
How do I implemement MVVMCross in a "Blank Android App"
Is it possible to do this without a Portable Class Library (PCL)?
Do I have to create an App.cs class (The project doesn't come with one included) and is that even possible?
If I do have to then how do I do it?
A good example for startes is the TipCalc-Tutorial which you will find on the official github page (https://github.com/MvvmCross/MvvmCross/wiki), just be careful since most tutorials are for 4.0 so there might some changes. As a example:
When asked to choose platforms, select .NET Framework 4.5, Windows 8,
Windows Phone Silverlight 8, Windows Phone 8.1, Xamarin.Android and
Xamarin.iOS - this will ensure that the PCL is in Profile259.
Is outdated since Silverlight isnt supported anymore from MVVMCross 4.2.2 onwards. So you should use Profile 7 as a Example. More informations for PCL Profiles here: http://danrigby.com/2014/05/14/supported-pcl-profiles-xamarin-for-visual-studio-2/
But yeah you basically should have a Portable Class Library, even if it would work without it. It just gives many advantages without requiring much effort.
And you dont need a "App.cs", but you need a class which inherits from MvxApplication. So it might be easier to stick with that name, since everyone knows then what it is for.
But just check out the tutorials first, everything in there should be explained.
After doing some research I found that you can create an App.cs file (ie a class that extends the Android.App.Application class) in a 'Blank Android App' and hence don't need a PCL to use MVVMCross.
You must ensure that you have an implementation of the public App(IntPtr javaReference, JniHandleOwnership transfer) constructor and some people state that you also need to override the OnCreate method (as i have done).
Also make sure that in your AssemblyInfo.cs file you DONT have a any [Application] lines ie. None of this: [assembly: Application(Debuggable = true)]
See code below.
using Android.App;
using Android.Runtime;
using System;
namespace YOUR.NAMESPACE
{
#if DEBUG
[Application(Debuggable = true)]
#else
[Application(Debuggable = false)]
#endif
public class App : Application
{
public App(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
//Do MVVMCross setup Here
//Mvx.RegisterType<ICalculation,Calculation>();
//Mvx.RegisterSingleton<IMvxAppStart>(new MvxAppStart<TipViewModel>());
}
public override void OnCreate()
{
base.OnCreate();
}
}
}
I'm learning to use GestureDetector and following android's official developer's guide, but when I try to run a snippet of code I met a problem..
public class MainActivity extends Activity implements
GestureDetector.OnGestureListener,
GestureDetector.OnDoubleTapListener{}
Here Eclipse gives me a error: GestureDetector cannot be resolved to a type, I tried to fixed it by cleaning and rebuilding, re-import android support library and including it in the build path and pressing ctrl+shift+o as well..but my Eclipse is just not letting this error go away...
Please give me some advice and I really appreciate that.
P.S., I'm following codes on Android Gesture Detector Training
try writing this code in your activity
import android.view.GestureDetector;
This will do the trick.
I tried to make my own small calculator, but I don't want to make all the business logic by myself. So I tried to use the javax.script since I heard that the javax.script needs a real JVM and is a JavaScriptParser. Then, I searched for other libraries with the functions I needed and found the project "exp4j". First, I made a small normal Java Project with JDK 1.7, and yes, it works with the source code:
public static void main(String[] args) throws UnknownFunctionException, UnparsableExpressionException {
ExpressionBuilder builder=new ExpressionBuilder("34*2");
Calculable calc=builder.build();
System.out.println(calc.calculate());
}
Then, I tried the same code in my model (MVC Pattern) of my calculator:
public void berechnen() throws UnknownFunctionException, UnparsableExpressionException {
ExpressionBuilder builder=new ExpressionBuilder("34*2");
Calculable calc=builder.build();
setErgebnis(calc.calculate());
}
But every time I got the same exception:
"AndroidRuntime(630): java.lang.VerifyError",
after I started the app. I can't click on the button that runs the method berechnen() because the app crashes after I start it.
I'm confused why my program doesn't work. When I delete all imports of exp4j and delete the source for the calculation, my calculator works fine.
My only idea is that the exp4j libaries is using a class or method that does not exist in Android.
Thank you.
You may have include jars twice, check once in libs folder and libraries in properties, I have faced same in the past What you need to do is to
Remove that in the libraries and paste freshly in your res/lib folder of android application project and then clear your project