How to find mapping between buttons and callback methods? - android

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.

Related

Optimize Tag based search in Android recyclerView with 1k+ items.

My Android app has a recyclerView of 1500-1700 items in the forms of cards, each card representing some textual data. Each card has certain tags on them [for example] #2016 #India #blue #music etc. Cards can have multiple tags.
I want to add a tag based search to this recyclerView. For example, when "2016 music" is searched, it should only show that cards that has both these tags, "2016" and "music".
All I can think of is, whenever a tag is added to the search bar, I go through all the items and remove all those cards that doesn't have that following tag. But Scanning 1500 items every time a tag is added to the search bar must consume a lot of time.
What would be the optimum way to implement a tag based search in recyclerViews with too many items?
All I can think of is, whenever a tag is added to the search bar, I go through all the items and remove all those cards that doesn't have that following tag
That is definitely a bad approach. The ideal way is to update the adapter. ie when user searches for a TAG , use Loader to retrieve data from your content provider, and update the adater's data and invoke notifyDataSetChanged().
Now there are other aspects to this question, like what data storage options to use for the fastest way, eg(mysql,realm,etc). Which you should choose according to your data size and other factors, which should be asked as a different question if you do not find much info after research(chances are scarce).
TIP
When building projects like these, it would be a best practice to follow an architecture, preferably MVC or MVP, which would make development and debugging easy, also would make the data flow perfect.
Links with further info on MVC and MVP is provided below.Choose which suits best for your requirement. Hope it helps.
Model View Controller pattern
MVP architecture in Android
Writing better Android apps with MVP
Android Application Architecture

Intuition behind View and adapters

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.

How To Make List Of Fragments In Android Programmatically?

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.

How to implement database search in an app where search is the main focus?

I'm developing an app that calls a database via REST API from a main view and returns results in JSON format, to be parsed and displayed on a new view likely in ListView format. From the results list view, users can click on a specific result and see a "place view" with information specific to that place. The originally returned JSON objects that populated ListView will likely be used to populate the place page. I've been doing a lot of research about how best to implement this, and there doesn't seem to be any right answer or consensus. A few of my questions:
Should the main search and results listview be one activity? If they are, it seems like I can use AsyncTask to make the search to
the external database. Is that a good use of AsyncTask?
If main search and results are separate activities, can I still use AsyncTask, or do I have to get more complex and use a Service to
make that call? I've gotten the idea in my head that AsyncTask only
can be used within an activity, and not to take a search term from
one activity and return results to another. Can someone clarify that
for me?
Is there a single proper way to implement this type of very common search?
Can anyone point me to sample code that illustrates a similar search and response being done? I have sample code and understanding
of creating the actual REST methods, but I'd love to see some code
that shows a search structure like mine (rest api, input and results
in different views, etc) being implemented properly.
Thanks for all your help.
I had to develop an app with very similar functions as the one that you are working on. Here are some ideas of what I would do in your situation:
Should the main search and results listview be one activity? I would say no, its better to separate the the main search into separate activities.
If main search and results are separate activities, can I still use AsyncTask? I used the IntenetService ResultReceiver pattern. I found that once I had set it up, it was very easy to adapt to any rest calls. Here is the link that I used to learn how to use it. Modern Techniques for implementing Rest clients.

Where can I find a good example of FastScrollView?

I have a long "cities" list. I was looking for an equivalent to
sectionIndexTitlesForTableView in the iphone world. It provides a way to "jump" to a particular point in long lists without having to scroll through all the elements. I think FastScrollView implements this but it's not part of the API and I can't find any documentation on how to use it. It appears in the baked in contacts application of the device. I want to use this functionality within an AlertDialog. Is this possible?
Fast scroll can be used for any list; the most common being the alphabetical lists. You can write your own custom SectionIndexer for other fast scrolling operations such as moving to a list based on some other attribute of your list item (e.g. name, address - where section indexer will be alphabetical, and phone number, address etc where it can be numerical)
P.S. This is more of a comment aimed at matto1990's answer.
Fast scroll is something you can only use in alphabetical lists really. The view which pops up (to show where you are) can only provide space for a single letter. I've looked in the source code for ways to extend it, however lots of the methods needed are protected and can only be used by classes in the same package (the core framework one).
The only thing I can think to do is to just write it all yourself. It's annoying but until Google make it possible for us to extend it via an API that's the best that's possible.
My similar question

Categories

Resources