There are several articles/tutorials to use Accessibility service on Android to find elements by id/text but there is None (that I could find) which makes use if XPath.
As far as my understanding goes, Accessibility service would take a snapshot of the current ui hierarchy with corresponding attribute and then would search the id/text.
This is significantly slower than having a direct XPath to the element we already have knowledge of - no need to take snapshot of whole ui or search for text in it. (Please correct me if I'm wrong) and can even interact when the item is below the screen; i.e. it has potential to click item when it's not visible yet and will be so after scrolling.
Android does have support of javax.XPath https://android-doc.github.io/reference/javax/xml/xpath/package-summary.html but I couldn't find any sample to try it on.
Any link/resource/guidance will be appreciated. Use of external libraries is fine as well assuming it doesn't hinder performance. Idea is to click an element (I have XPath for it) as soon as it is inflated/rendered in apps making use of some kind of webview element.
What is the intuition behind views and adapters in Android, that means from where did the person who made this concept get the thought process necessary to create these elements? To elaborate, the concept of circle originated from nature, moon sun such celestial bodies, like wise what is the intuition behind using listview and adapters?
As you probably already know, using ListView (and more recently, RecyclerView) on Android requires the use of an Adapter to get the data from the data source and turn it into something displayable which can then then be shown in the list.
So why did the engineers at Google implement ListView and the backing Adapters the way they did ?
It essentially comes to a few things:
Performance:
Imagine you have 1000 contacts, each with a picture and various pieces of information. You want it to work well, load quickly, and scroll smoothly. The naive way of doing this might be to create a scrollable layout to hold the contacts list, and then simply add a sub-layout for each contact. Unfortunately, this will fail all three requirements: It won't work well, as there won't be enough memory (ram) for all those contacts and especially the associated pictures, and the app will run out of memory and crash; It won't load quickly, as all the contacts and the contact pictures have to be loaded into memory before the list can be shown, which will take a long time; And it won't scroll smoothly because you don't have all of the advanced caching, pre-rendering, and bitmap texture caching that ListView and the adapter does. Use a ListView and an Adapter, and it solves all these problems for you.
Adaptability and ease of use for developers: ListView and Adapters are used for lots of different things, from contacts lists all the way to to complex pages with different answers, comments, and tons of other information in the Stack Exchange Android app. Adapters make working with data from different sources easy: there's a single, common API, which can be used and extended to display any kind of data, much more easily than if every developer had to implement their own solution. Want to load more data when the user has scrolled to the bottom of your list ? Sure, it's easy. Want to have different kinds of items in your list ? Sure, It's really easy.
So, did Google and the Android developers and engineers invent this idea of using adapters ? No.
In fact almost every system or environment which involves showing a list of items uses something similar: The actual list of items, an Adapter behind it, to transform the data and make it displayable, and then the actual data source, which can be anything which gives a list of items, from a database to a web service. It's essentially this: data source > adapter > list where it's displayed. This kind of pattern is used in desktop Windows applications, on iOS, web applications, so the Google engineers took this concept and adapted it to Android.
That's why ListView and Adapters work (and are used) the way they do.
PS: here's a Google IO video by the Google engineers on how to use ListView and Adapters correctly, and a little bit on how they work under the hood: http://youtube.com/watch?v=wDBM6wVEO70.
I'm working on an Android application and one of the features is a list of upcoming events. I need to be able to generate a 'card' so to speak for each of these events and place them in to a scroll view. This would be simple if I knew how many there were going to be and could prepopulate an axml file but I must populate the scrollview programmatically based off the parse of an xml file on the web so that the client can keep it updated. I've searched everything I can think and the best I can find is a custom list view which I do not think will provide the results needed. I've uploaded an example of what I'm trying to do to my google drive and linked to it below. I should also mention my background is completely C# and I've only been working with java for the last two weeks or so, so if anyone could provide a working code example I would be most appreciative.
https://drive.google.com/file/d/0B8alYNlu3SuoSEk0bE55cDhXWVE/view?usp=sharing
I think that basically what you need to do is to implement a RecyclerView using a LinearLayoutManager (this would represent basically a list) with CardViews as the items or just regular layouts designed by you, the CardView will just make your life easier if you need the Material Design cards appearance.
You have many different tutorials as how to implement this, as you can see here:
http://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156
You'll see there that it's exactly what you need but with smaller Cards.
Let me know if this helps.
I want to dynamically analyze an android application like yelp for security purposes.
I would like to find out if multiple items in the list view correspond to the same callback; if they do, I will not click these items during dynamic analysis.
Is there any way to find out mapping between UI elements and callback methods?
I am exploring Androguard but haven't come across a specific solution.
Appreciate your comments.
I have an application that uses predefined word lists but I want to extend it to give the option of using their own custom lists.
Unfortunately lists like SOWPODS (the official Scrabble word list) are quite comprehensive and contain words I wouldn't want popping up on the screen.
I can easily get hold of a banned word list and build it into my application as a kind of swear filter. Is this likely to get my app trapped by any application filtering that may be present on Google Marketplace and, if so, is there a way around it? (encryption, compression etc.)
EDIT: Most of the answers so far are missing the point that the user will be supplying the list so I have no control over its content and need to filter it in my app either on import or as it is used. (Though they will still blame me if the app "swears" at them)
Is there a reason you couldn't just filter the words upon import against a "bad words" list that, according to a previous comment you made, it sounds like you already compiled?
You could also add the option into a preferences menu so that it doesn't filter them on import.
Edit: Google's policies don't allow "excessive profanity." If it is rejected, I assume you could just appeal with the argument that it is a filter against profanity and your app would be accepted.
Random thought: why not build a Bloom Filter for disallowed words, and store the bits in the filter in your program's executable instead of the word list? Sure, you might get the odd false positive, but in the space of possible strings your word list is going to filter a lot more bits.
Alternatively, if what you're really worried about is someone doing a string dump on your application, some simple obfuscation like base64 should do the trick.
Many *nix distros include a word list in a plain text file /usr/share/dict/words (used for spell-check, etc.). On my OSX Leopard laptop the list appears to be stripped of the f-words. On my linux server, the f-words are there. Check your *nix distro with grep to see what you have and if it doesn't contain f-words, you could base your program on that word list.
Why not have a list of good-words instead of bad-words.. Much easier to find, and will make sure people can not trick your filter. I do however believe that users do not really like filters.
I would think the banned word list would be relatively small (what, 15-20 words?). I haven't done anything like this in Java yet, but I imagine it would be simple to, when the user imports a list, put that list into a binary search tree, and then check it against the banned word list, deleting any matching entries. Then save this filtered list and use it.
Just to add to this, I would perhaps have a popup dialog, or maybe a preference that allows the user to disable filtering. Always better to give the option. :)
I commented, but this is really more of an answer.
I think you need to learn how "spam" and "content filtering" works.
Neither of those things will prevent your app from containing or emitting any type of word. To be very clear, neither are going to search the binary of your application for those words.
That said, you can absolutely keep a list of words with your installer that you use to filter out what is displayed to the user regardless of what they upload.
BTW, "spam" filters are there to stop spam email from being received and hence block those. Content Filters work two ways. First, by letting the content providers explicitly state what audience their content is good for and second by filtering the data as it comes across. These do NOT work inside of an application; rather, they work on the data a web browser receives.
I would start with a standard word list. A separate program would filter out any bad words and create your own modified standard word list.
Your application would then not need to worry about filtering anything out. No garbage in, no garbage out.