Splitting display in Android for different Apps - java

I'm creating middleware app for android which in main think will allow people create games based on blocks easily. The idea comes from Siftables (sifteo cubes) - I'm creating Android version :)
The idea was to make middleware which contains GUI to display blocks and board, and allow players to move blocks. Middleware is connected with game (another app), which count score and do another basic things. And here comes my question. I want to split display into two parts - one for middleware GUI and second for game e.g. displaying score.
I found Fragments, but everywhere it was used in one application. Is it possible to display two fragments from differen apps at one time?
Thanks, for help :)

Is it possible to display two fragments from differen apps at one time?
No, sorry.
You can use RemoteViews — what app widgets and custom notifications use — to pass bits of UI from one app to another, though RemoteViews are limited.
You could create your own RemoteViews-like system, marshalling instructions for how to build a UI and pass events, then use that between your apps.
On Android 7.0+, the user could enter split-screen mode, showing two activities side-by-side, and you might leverage that for what you are seeking.

You should take a look here:
https://developer.android.com/guide/topics/ui/multi-window.html
But as CommonsWare mentioned, it is only from Android 7.0 officially.
With same hacks, you can use it it lower Android versions too, but root necessary.
Or you have to use manufacturer specific APIs, if it is supported, like on Samsung devices:
http://developer.samsung.com/s-pen-sdk/technical-docs/Designing-For-The-Galaxy-Note-Creating-Multi-Window-Apps

So, I think the best option would be splitting middleware GUI for GUI and part for game, so game would send data to middleware and it would display it.

Related

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...

Android: How to develop multiple apps in a single apps?

I am developing some android app. They are about 9 of them.
I dont want this apps to be seperated or indipendent of each other. I want to them to be in one sigle app but each apps has a different function is carries out.
How do i go about doing this? I just need some guidance. How do i include the other apps in one sigle app, so that it will be on the fone a single app but within it should be multiple different apps, performing different functions.
Thanks in advance.
Develop on app in which at first screen place 9 item (as per you app no) like grid or as per your choice and on hat item click start activity related to that app.
Like in attached image
For A reference you can install Libraries for developer app in you device and take a look that how then integrated lots of demo app for different different libraries.

How to make my App modular?

Hi and thanks for your attention.
I have an Android App (Java) whose code is growing (and eventually will need to grow more and more).
So I have to face the fact that I have make it somehow modular to make it manageable.
So I am here to ask some advice on how to go about it.
Basically the Apps consists of 2 screens, lets' call them A and B.
The App starts with screen A, which is a quiz, if the user responds correctly the screen B is displayed, showing the results; if the user wants to go on and take another quiz the App switches again to screen A, and so on in an infinite loop.
Please can you give me some advice no how to make this app more modular, to avoid all the code written in 'onCreate()'.
In particular how could I implement communication between the modules: how the Quiz module would communicate to the main and ask to switch the screen from A to B; how would the actions performed on screen B would communicate again to the main and ask to switch again to A.
I know it is a very open question, I am looking for some guidance, any suggestion very much appreciated.
For communications between screens, you could use sending messages or better Observer pattern. If you change something on screen B, it call screen A method, that do something.
Generally, for your problem, look at design patterns. Some of them could be usefull and they are widely supported in Java.
I am not very familiar with Android, but iOS has notifications (similar to triggers). Maybe something like that exist also for Android.

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

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.

Possible to 'layer' Android applications?

I know this in general is beyond the scope of SO, but I am looking for some basic yes/no info to see if it is even feasible to proceed... I am thinking about building and Android 'note-taking/annotation' app that runs 'over' other installed Android apps, such as the web browser for example.
Essentially, while the user is browsing, my app would be running in the bg as a service, and then they could activate it which would then essentially intercept user inputs and translate those on a transparent canvas over the web browser into lines, shapes, etc. The user could then take a screen-cap of their marking with the underlying web page, which would be stored to the sd card.
This is a very good idea and a great question, but sadly, I do not believe it is possible.
The way Android is designed only one Activity can have focus at a time, while a Service could run in the background, the user would not be able to interact with it. The user can only interact with the currently active Activity.
Again, love the idea, but it is sadly not supported.
You might be able to achieve this with the WindowManager service. You can then use that to call addView() with a view of type TYPE_SYSTEM_ALERT, or possibly TYPE_SYSTEM_OVERLAY (but see the notes in the documentation about taking input focus).
I haven't tried it myself, but I've seen several apps (often dictionary apps that translate whatever words you tap on) that do overlays, and they always seem to require the SYSTEM_ALERT_WINDOW permission.

Categories

Resources