I'm desperately attempting to disable audio-focus in an application I'm developing, but to no avail.
I have two web-views each one paying a video and i would like them to play at the same time, but it is not possible as they steal the audio-focus each other and get paused.
To my understanding, this is happening since the web-view engine interprets the html element and convert them into android views, and the video element, it is converted into a standard video view, with its default settings of audio-focus.
If i could access the video views i could set a different audio-focus mode... maybe.
But i cannot find this views anywhere, i thought maybe are hidden children and i can expose them with java reflection in the debugger, but I couldn't, maybe I'm searching in the wrong place. Any help?
To be fair that idea of the audio-focus of the single video view might be flawed, as I was able to reproduce two videos in the same web-view.
Related
i am trying to create an activity for users to input data in an android application. Many inputfields are required and i therefore wanted to make them into multiple fullscreen scrollable pages.
Like this only with input fields in each slide
I have downloaded the code from this git: https://github.com/akrajilwar/Android-Intro-Slider-Screen, but i dont know how to put input fields in each of this views. As you can see in the git; each of the sliding pages are different xmls but they have no corresponding java files. All code is in a java file which has a viewPage in it.
I am struggeling to come up with any ideas on how to do this. I cant find something similar any place on the internet and need some advice for how to do this, either building on what they already have done in the git or something completely different.
Is it possible to create a service that collect touch screen interaction data? I have seen that this could be possible in earlier versions of Android but seems to be much more difficult to achieve now. I have found many questions on Stack Overflow that already attempt this solution but don't offer a solution. The problem is also outlined here.
I wish to record the x and y coordinates of each tap and swipe interaction for medical analytics of different user groups. This includes recording scrolling data in (for example) the web browser. So far I can't get it to do this outside of the default application. How can I build a service for this?
I have tried adapting the code here, but nothing seems to work outside the application when other applications are running.
While working on my Android application, I recently check a task manager to see how memory my application is racking up.
Right now my application has two ad banners being executed by AdMob services and then an interface fragment for a Google Map. Aside from all that I then have a menu in which I utilize a container to which I add views to it in Java code. I prefer this over a list-view as it is more light weight and easier for me to structure what I want to do with the views (and I can use Androids native animation system when adding/removing the views).
The views being added to the container are being added by a loop structure based on conditions. The views in their interface structure also have a small image-view utilizing a small local drawable.
All of this is somehow adding up to my application 44.8 MB in memory which seems abnormally high from previous development numbers. This is also the first time I decided to use the container to add views through a loop rather then the adapter with list-view method.
Can anyone tell right off hand why my application is taking up so much memory right off? This is my first time utilizing all these components: AdMob Banners, Google Maps, and Containers with added Views.
My LogCat shows no warnings of doing anything inefficiently. Just curious to see if I am doing anything wrong. If anyone has any ideas I am open to provide any source code.
I think 44.8Mb is pretty normal for a modern Android application. My bet is on Google Maps since it's very resource-consuming library (both CPU-wise and memory-wise). Anyway, you can try to sequentially remove each of the component out of app and see how it affects memory footprint.
As Andrey have already said, 44.8Mb is not too much for an Android application. But you can use DDMS to track allocations and heap updates to see exactly is taking up this memory. See this: https://developer.android.com/tools/debugging/debugging-memory.html
Besides, I would recommend using a ListView with adapter because items in ListView can be recycled, which can improve performance considerablly (See this tutorial).
I'm building a Java application that is some sort of Android applications (APK files) analyzer.
One of the main features that the app will offer is a "preview" of an Android layout, hence I need an API that receives an Android layout XML and a few configuration arguments such as screen resolution and theme, and returns the rendered layout as it would appear on a device running the application (graphical consistency with the real Android platform is important) along with position data of the View objects (in order to allow the user to select a view by clicking it). At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
The idea I have in mind is to use the source code of a layout editor, such as ADT's editor or DroidDraw, and integrate it into my framework, but then I was wondering - maybe a better way would be to use the android API itself to render the layout for me (this is better mainly because I won't need to rewrite my code for later versions of the OS).
So my question is: does the API allows such operations? Or is there an even better way?
Any suggestions and insights are welcomed :)
does the API allows such operations?
If by "java application" you mean an app that runs on your PC, then no. There's no straightforward way to even call anything in the Android API. I'd recommend you go with the first approach of integrating some existing source code.
That said, this is not a straightforward task either. Also, if you're analyzing an APK, you'll be working with binary XML files, not the easy-to-read plain text ones that you see when developing (which assumedly are what ADT/DroidDraw use). There may be source code out there to deal with that too.
You could also consider looking at the source for Android itself, but I imagine you'd have to re-implement a bunch of rendering code, so that's no easy way out either.
At the first stage, I don't expect the feature to reflect layout changes that are made programmatically, but only the View objects and resource graphics defined in the XML.
Reflecting the layout changes made programmatically will be virtually impossible to do in a reasonable way.
This task is definitely possible, however, it's not straightforward at all. I would suggest taking a look and Android Studio's source code, more specifically there is a tool called LayoutLib.
This is the tool that the IDE's layout preview/editor uses to render layouts. You can use this to render layouts and views that you have the source code for. Unfortunately, it's not very well documented, so you have to figure out the usage from IDE's sources.
The open source Itsnat has a way to render loaded XML Android Layout files directly. it has a sample app that compares the standard (binary compiled) versions with the dynamic. My work with it shows that it does a good job reproducing all the quirks of LinearLayout/Relativelayout, etc. https://github.com/jmarranz/itsnat
I wanted to understand how does the Android OS figure out which home screen the user is viewing currently and render the appropriate icons and widgets on that screen based on the user's left or right swipe on the touch screen of the device.
The OS must save a state of the screen and IDs or something relative to the objects placed on the screen to retrieve the state each time the screen becomes visible.
From my research I understand that Android OS treats all the 7-8 homescreens on devices as one single host.
Also my question might seem vague, but the reason why I am asking is because it seems reasonable that app widgets on android devices, update not only when the phone is awake but also only when the app widget itself is visible. I know that Google has declined the enhancement request by many others but I don't think that is good enough. Link here.
That is the reason why I am trying to give it a shot to understand and implement it for my app with whatever Android knows about the state of the home screens.
Any help or insight is much appreciated. Also the experts out there let me know if you think this can be even implemented for one off apps at all?
Well, as the link you posted clearly states, there's no way to know.
Also, if you consider the fact that "Home" is just an application like all the others, it makes even less sense to have a unified API for that. A lot of people use Launcher Pro or similar applications, which would probably not implement it.