Service Reference for android? - java

I have a service which I need to access from an android app. The goal is simply to send a number value from a textbox and get a result string back.
I know it is possible to do so in VB using a Service Reference, which I have done. Here is the sample code :
Private Async Sub Button_Click(sender As Object, e As RoutedEventArgs)
Dim service As New ServiceReference2.Service1Client(ServiceReference2.Service1Client.EndpointConfiguration.BasicHttpBinding_IService1)
Try
lblReturn.Text = Await service.GetDataAsync(CInt(txtValueSent.Text))
Catch ex As Exception
lblReturn.Text = ex.Message
If Not ex.InnerException.Message Is Nothing Then
lblReturn.Text = lblReturn.Text + ex.InnerException.Message
End If
End Try
End Sub
After research I can't seem to find any way to have a quick and simple result like it is possible to with Visual Studio using Android Studio
Are there any tools available which work in a similar way ?
If not which process would be recommanded to achieve the same result ?
Are there any usefull links which could help enlighten me?

Related

Unity AndroidJavaObject not working without showing errors

I have been trying to call a Java method in unity. Not working for me, even the simplest example from the docs
using System.Collections;
using UnityEngine;
public class ExampleClass : MonoBehaviour {
void Start () {
AndroidJavaObject jo = new AndroidJavaObject ("java.lang.String", "some string");
int hash = jo.Call<int> ("hashCode");
Debug.Log ("hash=" + hash);
}
}
Unity console prints hash=0, which is not the hash code for provided String. Even if I change and use java.lang.StringInvalidClass as class name, unity still reports same result to the console without notifying errors. I can even try to call toString, toStringa, toInvalid2 and they always return empty string without showing errors.
This is a brand new 2d project with only script displayed above, attached to camara object. I am using Ubuntu, Unity 2019.4 and project platform is Android.
Thanks for the assistance.
Answering myself after some time working with unity.
All examples in the web and unity documentation doesn't mention it, which is weird since it is something simple to mention and about confusions: code needs to run as an android application. Editor or even unity remote does not work, in order to use AndroidJavaObject and related classes, your code needs to run as an android application installed in the phone.

How to remove route in tomtom maps sdk?

Is there a way to remove the route without clearing the markers? Using function clear() is really bad.
tomtomMap.clear();
route = null;
origin = null;
destination = null;
Is there a function clearRoute() that do not clear the markers.
Take a look at the API reference
https://d221h2fa9j1k6s.cloudfront.net/downloads/mapssdk/APIReferences/JavaDocMap_2.4.376/index.html
I was able to test the function in my project and verified that it works.
tomtomMap.clearRoute() should solve your problem.
Regards!

BrowserMob + selenium + java. How to create new response filter during on test scenario?

I need to create one more response filter during one test scenario. But now when I do this both filters work at the same time. How could I stop or override the previous one without stopping current browser instance?
Code example:
proxy.addResponseFilter((response, contents, messageInfo) -> {
if (messageInfo.getOriginalUrl().contains(keyWord)) {
contents.setTextContents(newResponse);
}
});
It's not currently possible to remove a javascript filter after you've added it, unfortunately. The new REST API that is currently in development will support this, though. There's an issue open to track this: https://github.com/lightbody/browsermob-proxy/issues/326

Trying to check web content on android during Robotium test

My application is service running on background and making changes to network traffic. I want to make a test with Robotium calling for web source and checking the the page.
Here is my code for calling for web content:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
Log.d(TAG, "Looking for text ["+expected+"] at address ["+url+"]");
getSolo().getCurrentActivity().startActivity(i);
getSolo().waitForWebElement(By.textContent(expected), timeout, false);
Here are few things i have tried but with no result
bool foundContent = getSolo().waitForText(expected));
foundContent = foundContent | getSolo().getCurrentWebElements().size() > 0;
foundContent = foundContent | getSolo().getWebElement(By.tagName("div"), 0));
It is enough for me when the test checks "Yeah the page contain word porn" or "Nope the page contain word porn" but if its possible I would be glad if have access also to whole page code in string if its possible.
My first question here so i hope its OK
Thank you for help in advance!
P.S.: I read that solo object have method waitForWebElement returning bool (false when the content is not present till timeout) in 4.0 but in code (using 4.0 jar Robotium) and in other reference there is only a void. Is it something that they are still working on?

Calling Java method from HTML link

I'm currently building a Twitter client in Java using the Twitter4J API. To create a Twitter "timeline", I am currently pulling data from Twitter such as profile images, tweets and usernames, then displaying them in a JTextPane, formatted using HTML. Code example below:
StringBuilder out = new StringBuilder();
try {
List<Status> statuses = HandleEvents.instance().twitter.getHomeTimeline();
out.append("<html>");
for (Status status : statuses)
{
out.append("<img src=\"").append(status.getUser().getProfileImageURL())
.append("\" width=30 height=30><b>").append(status.getUser().getName())
.append(":</b> ").append(status.getText())
.append("<br><br>");
}
out.append("</html>");
tweetsTextPane.setText(out.toString());
This displays a timeline of 20 tweets, separated by two line breaks. Under each tweet, I would like to place a simple hyperlink, called "Retweet", which calls one of my Java methods - HandleEvents.instance().twitter.retweetStatus(status.getId())
How would I got about doing this? Can the call be made directly between the tags, or do I have to make the call using JavaScript?
Any help would be appreciated. Many thanks.
You don't really need to have a hyperlink do you? Since it's a Swing app you could just add a JLabel that only looks like a hyperlink (but if you put in a little effort, it could behave like one as well). Add a listener for mouse clicks on that JLabel and you've can hook your current handler there.
On the other hand, if you do want actual HTML links, what you can do is implement your own HyperlinkListener.
Here are a couple of examples:
http://www.java2s.com/Tutorial/Java/0240__Swing/HyperlinkListenerExample.htm
http://www.java2s.com/Code/Java/Event/DemonstratingtheHyperlinkListener.htm
http://www.devx.com/tips/Tip/12997

Categories