How do I combine a standalone Java application with an Android application?
I have a piece of code taken from the Google quick start examples that perform a task that I can't seem to be able to combine with my activity source code.
I'm of course talking about the following Google example: Sheet API, if I just add it as a standalone class and tell Android Studio to run this application, before my Android application, then it will produce what the code is suppose to do.
If I try to copy and paste the exact code into one of my activities it will give a couple of problems. One is that it can not find my keystore, another is a threading issue which I understand, another being that it can not find the credentials (even if the file is present), the newTrustedTransport-method call will be an issue, the setDataStoreFactory-method call will be an issue, file creation even with the correct uses-permissions and so on.
What is going on in the background that would make exactly the same source code work in one instance and not the other? What do I not know about Android Studio, and how an Android project works in the background for me having these issues?
I had an idea that I could just keep this standalone application as it is and store a file with the result that this Sheet example would provide me. But, since I do not have enough experience with Android Studio I have no idea if the result will be available for the actual Android application once it was made into a release. Will it? I can't save the output file generated by the Sheet example, under the res-folder, under the app module for some reason (scope?).
With other words... Can I have a standalone application, that is tasked to run before the Android application, to gather data and it will be doing this EACH time the Android application is run on a client? I feel like it would be stupid if the IDE would present this like this would actually work but then when the application is made into a release then the standalone application will not "follow" and be part of the release...
If I could just combine the source codes, I will not be having this issue at all. No examples online, neither Github or Youtube can provide me with answers on how to do this. Many examples online provide me with source code that is either out of date or just not what I'm looking for, and I really hate Google's way of explaining things. Just look at how they give code examples under this page: Google API Client Library for Java, and not give a full example where they would fit into the a project. Maybe all I need to make everything work is to use the code under "The library runs on Android 4.0 or higher (#Beta)."
Related
I have created a Java program that utilizes Chrome Driver, Selenium, and Java Excel API. The program is used to automate a few different processes on Google Chrome. Currently, setting up this automation is more complicated than I would like it to be: the user needs to download a zipped folder, unzip it, download the Java Runtime Environment, and launch the program using the executable.
My goal is to simplify the installation of the automation. Ideally, a user would come to a SharePoint website, fill out a form with the parameters of the automation (potentially upload an Excel Workbook), click an "execute" button, and the automation would run. As a result, the automation would run seamlessly across platforms (Windows and MacOS) without any modifications.
I have researched changing the programming language to achieve this functionality. I concluded that a different language could remove the need for a Java Runtime Environment download, but it would still require some type of installation process. Additionally, I have researched using HTML/JavaScript, but I concluded that this is not possible because the functionality (triggering a web automation from a website) could be used maliciously without the user's knowledge. Finally, I began researching containerization through Docker. This solution seems promising but I do not know enough about it to determine if it is the appropriate solution.
What would be the best route to achieve the results that I am looking for (outlined in the second paragraph)? I have access to enterprise-grade databases that I thought may be useful. Would it be possible to have the form trigger a virtual machine to run the automation on a remote database and then output the result to the user once it has finished?
Thank you in advance for any guidance you can provide. I do not know much about making a Java program into an enterprise-grade application so any information about what to research is extremely useful. Finally, please do not hesitate to correct my logic at any point in this question as I may have drawn the wrong conclusions from my research.
You want to look into creating a jar file with your selenium code.
So I have a pretty basic Java app I have been writing in Eclipse.
I now have realized somewhat late that I want this to run as an applet on my website.
How do I setup JApplet? (assuming this is what I need to use)
Is there any "quick fixes" for assuring that the app will be able to be used as an applet?
This should get you started http://www.dreamincode.net/forums/topic/28410-application-to-japplet-and-reverse/
It was the first item in a Google Search, so next time look there first.
I want to build a application like TwitterCount. Do anyone know any open source application like it? I want to find a open source application which can show some diagram or graph on website. Moreover, I want to build a web application, in which I can copy URL to my application, and it will show some diagrams. Now, my main difficulty about it is how to build a website like this, so I want to get some open source code for reference. If it is implement by java, that is better. Please give me some suggestions.
Twitter4J is a Twitter library for Java.
I have a random Twitter bot that I made if you want to see the source.
Here
Good luck!
I've been having tremendous problems with connecting my android app to the youtube API. Firstly I tried to go along the route of using the native youtube gdata java client(http://code.google.com/p/gdata-java-client/). I had read that this could then be integrated into an android app easily enough and so I set about doing that but I would stumble every time at the line
YouTubeService ytservice = new YouTubeService("AppName",Dev_Key);
I'd enter the correct details here, even have all the necessary external jars but every time I would be given a NoClassDefFoundError reporting that YouTubeService could not be found and neither could it's superclass, MediaService. (Just so you know, I had gdata-youtube-2.0.jar, gdata-client-1.0.jar, gdata-media-1.0.jar, guava.11.0.2.jar and jsr305.jar)
So then I tried which appeared to support android (http://code.google.com/p/google-api-java-client/wiki/Android). There was even a sample example where google tasks had been integrated so it looked promising. It didn't have an actual YouTube class like it did have a taskService but it did support OAuth 2.0 login which I could work with by just sending off URL requests to the youtube API with OAuth 2.0 authentication. I tried this but when the only key I could get from it in combination with android's AccountManager was an auth key token. Posting this with the URL request to google resulted in an 'authentication required' response from youtube(because i was providing an incorrect access token, it was at least twice the size of a working access token i was comparing it with).
How can I find the access token that I need for the youtube API from the AccountManager? Or even better, how can I get the YouTubeservice to work?
Thanks
rory
Edit
Amad, thanks for the answer but unfortunately that is what i am already doing:
(source: themobilelook.com)
maybe it'll help if i supply my project folder: here it's a barebones setup, literally just to test if the YouTubeService works.
using adt 20, jdk compliance level 1.6
if you manage to create a working version then itnwoild be great if you could share it
The YouTube API library/libraries must be included in the project. By going to the Project Properties > Build Path > Order and Export tab, you can tick the checkbox next to the all YouTube-API-related libraries to ensure that they will be included in the project when you export it. Make sure to clean and rebuild after doing this.
As for the access token... not totally sure. The documentation may help there. This Google Groups thread may help also.
If you get NoClassDefFoundError during Runtime, then I suspect you did not include them to work at runtime. You have to check the checkbox for each .jar like this:
(Of course you have to add them to your java build path first)
I am confused about the approach for application that am writing. I have developed the application jar and will be distributing via java webstart.
Now i need to putup a website supporting my app.
doubts i have
1)Can i pass this username and password to the jar that i will be launching?
2)Can the webcomponent calculate the time for which the app was launched.
Basically i need to understand how will the webcomponents and my java app interact with each other in terms of any data required to pass to the app and any info retreaving from the app and putting on the web.
Thanks
Krisp
I want to pass arguments like username to the JNLP and then want to pass it to the main class.
Is there any direct way to do so rather than use database?
since JNLP is just an xml file. I could not find a direct way to do so.
Can i anybody refer me some working code example.
Database is probably your best bet for sharing data between both apps. Other options are web services, sockets, RMI, etc.. You will probably need to look into all, on the surface initially, to know what suits you best.
As for the Calculation of the time in my java app i can use currentTimeMillis() to calculate the time for which my app is running.
But senarios like app getting crashed or forced termination of the app it will not get saved.
Any Hints for communication in terms of data between the web and Application jar?
Thanks
Krisp