What's the right approach for creating an Android app? - java

I have a great idea for an Android app, but as I'm only familiar with php/js, I'm uncertain of which approach I should choose for creating it. The app will be based on a google map with a lot of position markers. There won't be any fancy animations or other heavy resource-demanding activities.
As I see it there are three different options:
Read up on Java and program the whole thing in Java
Create the map activity in Java as a mapview and then use webviews for the other activities (which can easily be scripted as html5 webpages.)
Script everything as a webapp (not really an option, as this is not a real mobile app imho.
I'm most keen on using no. 2 as I'm quite familiar with html/php/js/mysql. Have to read up on the html5 specifics, though. Questions:
I need access to GPS and camera hardware. Is that acheivable in webviews?
How complicated is it to pass variables between js in webview activities and java in other activities?
How big a difference in performance can I expect if I use option 1 vs option 2?
Other thoughts?
Kind regards,
Anders

You can choose number 2, but as we are talking about an android phone, you might want to get really accurate coordinates for your map, and you can only achieve this by accessing your phone GPS, through webviews the best you can get is the location trought the device internet IP adress, wich doesnt lead to a very accurate geo position.
The best choice is a 100% java application in my opinion.

1) Yes it's possible, but as commented it will be less accurate and probably slow.
2) Not complicated. Painful if you need loads of interaction between a webview and native app. Using a Javascript Interface that can be set up from the native app. You can basically inject javascript in a webview's html.
3) Heterogeneity of performance depending on device. Because your implementation will be based on the device's browser you can expect to get really sluggish behavior for older devices. Anything to do with HTML events (Dragging, Tabbing...) will have a knock on most devices, from my experience.
4) As #vodich comments there are other party frameworks. My benchmarking on PhoneGap and other js-based options is that they're a waste of time if you are looking at developing a professional app. I haven't developed on Adobe AIR but find a pain the need to be installing plugins to get native functionality (access to sensors, camera, etc) Mobile is all about fast, responsive behaviour. HDI is your finger, user is fast, so app needs to be fast.
EDIT: So hell yeah! Java FTW!
Albert.

4.Other toughts?
Yes, if you really want to make a great Android app, you should be using only Android and specific Android UI components, and give it a native look and feel. And regarding 1,2 yes it is possible, I would say not so complicated to just integrate them, but I think you'll eventually get in big problems.

Learn Java and write your application natively.
Webviews might allow you to use your php skills to present something to the user, but it's entirely one-way - you'll not be able to interact with what's inside.
The Android developer site offers fantastic documentation and jumping from PHP to Java isn't greatly difficult, though you'll need to get used to strict typing and "real" OOP.
Other thoughts? Don't go down the PhoneGap/Cross platform toolkit road - it might allow you to write applications for multiple platforms and using your current skills, but in the end you get a subpar app that doesn't feel right on either platform and doesn't fair well as future versions of iOS and Android are released.

Related

Use Java or other languages in a Flutter Application

Since I got no answer and not much feedback on this question: Android Flutter Analyze Audio Waveform
and found nothing online about what I'm looking for, I'll simply ask a broader question, since a comment on that answer told me to use native code and use a platform channel to connect it to flutter but when I asked some clarifications I got nothing.
So my question is If I can do operations in Java (which has been around since a much longer time, and thus has a way bigger documentation), and then use the outcome in Flutter.
More precisely, could I do these things in Java and Flutter:
1) Analyse Audio waveform and find peak points in specific frequencies, and use the timestamp to display them in flutter;
Edit 1:
What Are Peak Points?
This Is the waveform of different frequencies ranges (The Orange one is bass (80-255Hz)), and the Points circled in black are Peak Points. I should analyze the audio specter of a song and Find the peak points in certain frequencies. Then When I Find the Peaks I need to save the timestamps, for example, 16 seconds in and so on.
2) Edit 2:
I need to Edit some photos in a video, like a video collage, for which each frame of a 30 or 60fps video is an image.
3) Edit 3:
I need to add basic frame specific effects to the video, for example a blur that will change frame to frame, or a glare.
4) Adding Music to that video and save it to an mp4 or avi or any format.
5) Edit 4: Most Important thing, I don't want to this all in real time, but more like an After Effect like Render process, in which all the frames are rendered together. The Only thing that would be nice is a sort of progress bar telling the user that the Render is at frame, for example, 200 of 300, but I don't want to display any of the frames or the video, just to render it in background and then save it to an mp4 video that can be viewed after.
As You can see it's a difficult process to do in a language to which you hardly find a tutorial on how to play music due to its early state. But Uis and some other things in flutter are way easier to do and Flutter is also Multi-Platform. So I prefer to stick to Flutter language.
Edit 5:
I took a look at Qt and JUCE, and found out that Qt seems a valid alternative but it seems for what understood more like a "closed" system, I mean, for example I looked the multimedia library but for what I've understood, you can do basic stuff, for example play a video, but not collage frames and save it. (Don't know if I explained myself well). JUCE On the other side, looks better but it seems more for PC audio VST than for mobile applications including video rendering. And another thing is that these two are not free and open source like Flutter is.
Then There is Kivy, which could and could not be the best, because it is a Python port for Mobile Devices and I have a lot of experience with Python And I think it's one of the easier language to learn, but on the other side, it hasn't got that much UI power. and as you mentioned there could be problem using libraries on Android.
You stated I could use C++ or Java With Flutter, but with C++ you told that it's a difficult process. So My question turned out to be Could I write the process in java with a Normal Android Application And Then in some way use the functions in a Flutter App?
Edit 6:
I found a possivle alternative:
Kha (http://kha.tech/). But again found nothing on how to use it with Flutter. Could it be a good Idea?
I'm asking more of a confirmation on if I could use Java or any other language to do what I need in a Flutter Application. And If yes if it's complicated or not that much. (I'm a beginner sorta). But Some tutorial or links to kickstart the code would be helpful aswell!
Flutter at this time is great for building UIs but as you've mentioned, it doesn't have a lot of power or compatibility with libraries yet. A good part of the reason for that is that it doesn't have easy integration with c++, but I won't get into that now.
What you're asking is most likely possible but it's not going to be simple at all to do. First, it sounds like you're wanting to pull particular frames from a video, and display them - that's going to be an additional complication. And don't forget that on a mobile device you have somewhat limited processing power - things will have to be very asynchronous which can actually cause problems for flutter unless you're careful.
As to your points:
This is a very general ask. I'd advise looking up android audio processing libraries. I'm almost sure it's possible, but SO questions are not meant for asking advise on which framework to use. Try https://softwarerecs.stackexchange.com/.
Once again, fairly general and a bit unclear about what you're asking... Try sofwarerecs. I assume you're wanting to take several frames and make them into a video?
Some of those effects (i.e. zoom) you could definitely do with flutter using a Transform. But that would just be while playing in flutter rather then adding to the video files themselves. To do that, you'll have to use the video library in android/java code.
Once again, the video library should do this.
This should also be part of the video library.
I do know of one audio/video library off the top of my head called Processing that may do what you need, but not for sure. It does have an android sdk though. OpenCV would be another but only for video/image processing and I haven't used it directly with Java so I'm not sure how easy it is to use.
For how you'd actually go about implementing this along with flutter... you're going to need to use Platform Channels. I mentioned them in the comment to your other answer but figured you could look that up yourself. The documentation does do a much better job of explaining how that works and how to set it up than I can. But the TLDR is that essentially, what they allow you to do is to send serialized data from native code (java/kotlin/swift etc) to flutter code (dart) and vice-versa, which gets translated into similar data structures in the target language. You can set up various 'channels' upon which the data flows, and within those channels set up 'methods' which get called at either end, or simply send events back and forth.
The complication I mentioned at the beginning is that sending images back and forth across the channels between flutter and dart isn't all that optimal. You most likely won't get a smooth 24/30/60fps of images being sent from java to dart, and it might slow down the rest of the flutter ui significantly. So what you'll want to use for the actual viewport is instead a Texture, which simply displays data from the android side. You'll have to figure out how to write to a texture from android yourself, but there's lots of information available for that. Controls, the visualization of the audio, etc can be done directly in flutter with data that is retrieved from native.
What you'll have is essentially a remote control written in dart/flutter, which sends various commands to a audio/video processing library & wrapper code in Java.
If all that sounds complicated, that's because it is. And as much as flutter is very nice to build UIs in, I have doubts as to whether it's going to be worth the extra complications if you're only targeting android.
Not really related to the answer but rather some friendly advice:
There is one other thing I'll mention - I don't know your level of proficiency with programming and with different languages, but video/audio processing and such are generally not done in java but rather in actual native code (i.e. c/c++). As such, there are actually two levels of abstraction you're going to have to be dealing with here (to some degree as it will probably be abstracted somewhat or a lot depending on the library you're using) - c/c++ to java and java to dart.
You may want to cut out the middlemen and work more directly with native - in that case I'd recommend at least taking a look at Qt or JUCE as they may be more suitable than flutter for your particular use case. There's also Kivy (uses python) which may work well as there's a ton of image/video/audio processing libraries for Python somehow... although they may not all work on android and still have the c++ => python translation to some degree. You'll have to look into licensing etc though - Qt has a broad enough OS licence for most android apps, but JUCE you'd have to pay for unless you're doing open source. I'd have to recommend Qt slightly more than the others as it actually has native decoding of video frames etc, although you'd probably want to incorporate OpenCV or something for the more complicated effects you are talking about. But it would probably be on the same level of complicated as simply writing in java code, but with a slightly different UI style & easier integration with c++ libraries.

Getting user behavior on the Android Phone (App History, Browse History etc)

Is it possible to get the user behavior on the phone (for example Alpesh has an Android phone and he uses multiple apps, browser YouTube etc). Whatever he is doing on the phone I want to get all those things from behind (which apps he has installed, which app he opens and what he search on the phone, All these data I want to get programmatically so what all can be get in android).
For now I am aware that installed apps list can be get easily but I want to get usage history and what he do all on mobile.
This is not a code solution, but an answer to your question, so you can get start some where.
In my opinion your question title are asking about two things.
(part 1) Getting User Behavior on the Android Phone (part 2)(App History, Browse
History etc)
1- First part Getting User Behavior on the Android Phone:
There is a concept called context awareness. Short described; it is about gathering different information from the phone, like light sensor, motion sensor, sound, location or even user behavior etc. and depending on your app requirement and the gathered information:
You could send these information over cloud data store for statically usage
You could make your phone doing (behavior) different things depending on location, motion or what ever.
etc.
For context awareness it is an open area for pervasive computing research. And it is not just few lines of code to write, it is typically a complete solution depending on requirement. Example I have built a context awareness application to gather noise collected by phones from different locations for research purpose inspired from this framework, but I am pretty sure you can find other frameworks or even build your own, as I did in my case.
The mentioned framework has some examples.
2- The second part is about App History, Browse History etc.:
This is possible, but you still need to build a peace of software (App) to collect all these information (logs) from the phone. Hereafter you can make phone act on different conditions and/or again send it over a RESTful API over cloud service data store, there is no limit for it.
The problem is, there is no thing out of the box for your requirement. Even if you find frameworks you still need to research it and further work on it.
You can find different examples for your requirement, like to collect browser history, you can find SO question here:
Get browser history and search result in android
Or get list of installed application:
How to get a list of installed android applications and pick one to run
My point here is you need to solve small goals at a time and put your knowledge together at the end.
Both 1 and 2 can also be related to each other, depending on your achievement.
Conclusion
Make a goal to your project.
Define the main requirements and tasks of your project.
Research your options (Technology, Cost, Target Audience, What data I can or I should not collect, what is possible to collect, what is the limits, Privacy issues etc.).
Split your project in small assets and try to solve small problems/goals.
Finally you would be able to put the puzzles together and build your final application
but i want to get usage history and what he do all on mobile
This is not possible and shouldn't ever be possible. Each app is sandboxed by Android so apps cannot inspect what other apps are doing. Think about it, you wouldn't want apps to be able to intercept private information such as banking details.
Every app is isolated from the other ones. Unless you develop a system signed app, you will not be able to gather all that data.
What you could do is to develop your own Android Rom where you then develop your data collection the exact way you want. Then you need to distribute your rom, which is another story...

Possibly non-intrusive method to change complete android application code with a library

I'm having quite tough problem while developing a testing framework for android apps. The text got a bit long so the actual question is in bold for those that don't want to read the context.
Basically, what I'd like to achieve right now is to trace user activity while he's using the application as one of the features. There's my app that manages context data all the time and developer's app - the one being tested. My idea to do this was to get coordinates where user touched the screen along with taking a screenshot simultaneously. Then I'd use the coordinates to mark the spot on the screenshot to get the idea of what user was doing the whole time with the app. Take hints on user experience and trace crashes.
Non-system apps cannot take a screenshot for security reasons, but application itself can take a screenshot of its Activities without much trouble for non-rooted users, e.g. like here. My only hope here is to interfere with developers' code to implement the functionality of doing so while my testing app is running. Each Activity then would have to extend my overridden Activity instead of regular one, implement an interface, implement broadcast receiver etc.
I am going to write a library for developer who would like his app to be tested with my framework. I'd like it to do the job for me and be as non-intrusive as it's possible for him to use. How to achieve that the best way?
Ideal case would assume linking the library to project with maybe a small addition in manifest that'd get the job done and after just unlinking, removing that bit of xml in manifest for production.
That's an open question. I don't expect any bits of code, but some nifty Java trick, Android OS functionality or even completely other approach that'd solve my problem
I tried to be as clear as possible with the question, but that's a quite tough matter for me to describe so that could have turned out contrary. Don't hesitate to ask me for more details, to speak my mind more clearly or even rewrite the question. Thank you all very much for help!

Android flash vs Java

I've been thinkin about games on android and was thinking - isn't it EASIER to make a game in flash than in android using Java with android SDK ? I've only experience with Flash/AS3 and it's quite easy to create user interface, animations, layout and to write scripts.
As of Flash CS3 there are motion detection objects, so we can create really interactive games.
However I've not seen any flash game related for a phone( I mean with orientation and so ). Is there something I am missing like flash too slow on a android enabled phone?
This applies to applications too. I would like to hear opinions about Flash vs Android :)
you can create game in flash and adobe air will convert it in apk. adobeAir is version where you can create any game and just 2 or 3 step that convert it in apk.so you can publish it or play it in your android phone
Flash is not supported on Android 2.1 and lower, and some manufacturers no longer provide software updates for their older devices. I think Flash will also probably be slower (which may not be an issue if your game isn't very computation/graphics heavy) and consume more battery. It also doesn't take advantage of multi-core processors right now, but that may change in the future.
On the other hand, if you write your game in Java for Android, you will be limited to one platform.
As a compromise, you could try something like Haxe, which allows you to compile your code into flash, Java and C++, among others.

Whats the best way to start programming for my non-smartphone?

I have a general old-fashioned phone that has no special app system and uses Java (I assume ME) for the few applications you can use on it.
This is still a decent userbase and I'd like to start programming for this type of phone. I already know basic Java theory and syntax, so.. where do I get started for programming for non-smartphones?
Best programming environment for Java ME IMO is Eclipse with EclipseME. Includes lots of built-in stuff about packaging your midlets etc. The SonyEricsson wireless toolkit is great for PC-based testing and debugging, but don't forget on-device testing!
If you don't know much about Java ME's lifecycle, then get reading as widely as you can, and try lots and lots of examples. Start with the JSR-118 (MIDP2) javadocs; you'll want these open on your desktop at all times while coding.
Don't waste too much time with the form-based user-interface; I recommend either rolling your own using Canvas, or read about LWUIT.
You can do all sorts in Java ME and target a very broad range of handsets. HTTP capability is guaranteed, so you can hook up to a public web service, or create your own using something like Google Appengine.
Finally, you can release your app very easily on somewhere like Get Jar. Don't be put off by those who say "no owners of Java ME handsets want apps", you'll find the most popular user bases on this site will be users in countries such as India and Indonesia.
Good luck!
I would start with a book on J2ME and work from there.
Try Beginning J2ME: From Novice to Professional.
You could also download the J2ME SDK and play around with the example they give.
For tutorials have a look at the stackoverflow question https://stackoverflow.com/questions/584923/do-you-know-a-good-j2me-tutorial as mention in my comment.
I started with writing simple Flashlight application (choose how much seconds screen will remain lit) in NetBeans ME. And other app which I mange was Countdown with some graphics and sound. After that I found limitations too much annoying and now I'm waiting for my Android phone.
in short:
If you want to try it out - you don't need to buy books. There are plenty of tutorials around.
But, if you want to start deep development - don't waste time.

Categories

Resources