Sliding menu - Java for Android App Development

Sir, I am new to android,please help me to fetch data's from database to a sliding menu of the app

aswanthrc said:
Sir, I am new to android,please help me to fetch data's from database to a sliding menu of the app
Click to expand...
Click to collapse
This code snippet assumes you have a getter/setter class for News items. In addition I am using the ActioBarSherlock library so if you aren't using that but you are using fragments then you need to replace instances of "getSherlockActivity()" with just "getActivity()" - if you're just using standard activities then you get replace it with "this"
Code:
List<HashMap<String, String>> newsListItems = new ArrayList<HashMap<String, String>>();
List<News> news = dbhandler.getAllNews();
for (News n : news) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("listTitle", n.getTitle());
map.put("listDate", n.getDate());
newsListItems.add(map);
}
ListAdapter newsListAdapter = new SimpleAdapter(getSherlockActivity(), newsListItems, R.layout.list_news_nav_drawer,
new String[]{"listTitle", "listDate"}, new int[]{R.id.titleNews, R.id.dateNews});
newsListView.setAdapter(newsListAdapter);
The output of this code in my app is shown in this screenshot.
Please let me know if you need any help in understanding the code

Thaq
thaq...

Jonny said:
This code snippet assumes you have a getter/setter class for News items. In addition I am using the ActioBarSherlock library so if you aren't using that but you are using fragments then you need to replace instances of "getSherlockActivity()" with just "getActivity()" - if you're just using standard activities then you get replace it with "this"
Code:
List<HashMap<String, String>> newsListItems = new ArrayList<HashMap<String, String>>();
List<News> news = dbhandler.getAllNews();
for (News n : news) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("listTitle", n.getTitle());
map.put("listDate", n.getDate());
newsListItems.add(map);
}
ListAdapter newsListAdapter = new SimpleAdapter(getSherlockActivity(), newsListItems, R.layout.list_news_nav_drawer,
new String[]{"listTitle", "listDate"}, new int[]{R.id.titleNews, R.id.dateNews});
newsListView.setAdapter(newsListAdapter);
The output of this code in my app is shown in this screenshot.
Please let me know if you need any help in understanding the code
Click to expand...
Click to collapse
what exactly does the ActionBarSherlock do? [emoji16]
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

Masrepus said:
what exactly does the ActionBarSherlock do? [emoji16]
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
http://actionbarsherlock.com/
For the purposes I use it for I guess I could use android.support.v7.app.ActionBarActivity but I started work on the app before the support library was updated (only been working on it off and on during spare time so its taken ages) and I'm way too lazy to go back and refactor/recode the needed bits now when I'm 90% finished

Thanks buddy
Haha okay i see
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

Related

Problem with virtual device in eclipse

I have problem with emulating basic „Hello World“. I create AVD as Nexus 4, choose project hello World in Run configuration, as target I mark my own AVD and then confirm Run. Virtual device doesn’t start. What’s wrong?
I work on macbook pro early 2011 i5, 4gb 10.6.8
Jdk 7
All packages like Tools or Android 4.4.2(API 19) Installed
You first have to go to avd manager and start your desired emulator there. Then after it is fully booted, run your project
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
You should also try the Genymotion emulator. It works so much faster for android emulation.
Thats right i also prefer genymotion as it gives you a fully, but really fully working avd that is even rooted. So suits every single app testing purpose you could need
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
Thats right i also prefer genymotion as it gives you a fully, but really fully working avd that is even rooted. So suits every single app testing purpose you could need
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
Thanks ,I'll try surely, I have no choice
Neozelkova said:
You should also try the Genymotion emulator. It works so much faster for android emulation.
Click to expand...
Click to collapse
Does it work like virtaul machine and on physical android device?
Genymotion is a virtual machine, but you can change some settings so that the internet connection is fully functioning plus you can acces google play through it as well
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

[Q] automatic responding to login prompts sent by websites

I want to get data from a specific web page at the background of my app. But before one can enter that page, the website pops up a dialog box asking for username and password. Now my question is can i automatically let my app submit the required two strings to that dialog box so that it can then have access to the data displayed on the website afterwards without any interaction of the user himself?
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
I want to get data from a specific web page at the background of my app. But before one can enter that page, the website pops up a dialog box asking for username and password. Now my question is can i automatically let my app submit the required two strings to that dialog box so that it can then have access to the data displayed on the website afterwards without any interaction of the user himself?
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
That's determined by the website. You *may* be able to pass the username & password as a http post, but that may not work. Depending on the site, they may have an API for external sites and apps to use for login.
Without knowing what site it is it's impossible to answer.
Mh okay it is my school's website and they dont have any apis or anything that i could use.
So you say i probably have the possibility to post it via http? Can i see that in the site's source code that i get when i use the 'show site source' function in desktop chrome?
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
Mh okay it is my school's website and they dont have any apis or anything that i could use.
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
In that case you need to look at the login page and see how that does it. It most likely uses a form that posts data to a url and that redirects you to another page if login is successful. Are you planning on asking the user for the login and password and then using that?
Yep that is what i am planning to do
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
Yep that is what i am planning to do
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
Just view the login page source and see how that does it. You can most likely do a http post to the login page and the change url to a signed in page once you get a response (assuming it was a correct response).
If you're not sure how to do that, here's a link I found for a Stack Overflow question that has a good looking answer...
http://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily
Hm i just checked again and i saw that if i just cancel the browsers pop up asking for the username and password, then i get to another page that tells me that authentication is needed and that i either provided wrong credentials 'or your browser doesnt understand how to supply the credentials required'
So i would think that there must be a way to submit those via http or something like that
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
This is the website: app.schyren-gymnasium.de/pw/mrekursiv.php
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Masrepus said:
This is the website: app.schyren-gymnasium.de/pw/mrekursiv.php
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
Click to expand...
Click to collapse
That page isn't using http posts to get username & password information. That's server authentication which is a completely different thing, and I'm afraid I have no idea how to pass the information in Java.
Have a look at this and see if it helps...
http://stackoverflow.com/questions/3283234/http-basic-authentication-in-java-using-httpclient
Oh okay that is a pity.. Well thanks very much for your time and efforts!!
Maybe i get it to work, lets see
Because at least i know now what to search for
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk
OH MY GOD I JUST SOLVED IT!!
You have to do http://username:[email protected]/pw/mrekursiv.php
I actually was trying to find it out through digging into the aosp browser source, but then by googling up some classname that i found i got the solution xD
---------------------------------
Phone : Nexus 4
OS:
Pure KitKat 4.4.2 stock, no root, no mods
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

Reading an app's R class

Hey guys,
I have some kind of sophisticated problem:
For my current development project, I need to be able to list all resources an app has. As there is no native method I had two ideas in mind:
(1)Using aapt
(2)Using Reflection
As I don't know how to use aapt on android and think that it's to slow, I dont really want to do it.
The next idea is reflection pretty much loading the R class from the apk and iteration through it's inner classes (R$drawables etc.) and getting the fields.
Code:
String pathToApk = getPackageManager().getPackageInfo(packageid, 0).applicationInfo.sourceDir;
PathClassLoader pathClassLoader = new PathClassLoader(pathToApk, getClassLoader());
Class resClass = pathClassLoader.loadClass(packageid + ".R");
for (Class classObject: resClass.getDeclaredClasses()) {
for (Field field : classObject.getDeclaredFields()) {
//classObject.getName() is the type of resource
//field.getName() is the field
}
}
This works perfectly but it stops working once the apps are obfuscated. Is there a better way to do this? Or has anyone an idea how to spot the R class in obfuscated apps?
Thanks in advance
Well i dont think it would be a sign of good security within android if any normal app could read the clear names of variables etc from another app when this one is obfuscated, clearly with the aim of preventing others from reading those names. Maybe there is a way of doing so by using root permissions but i also think this could be hard, because the key to de-obfuscate an app is only stored on the owners dev computer..
---------------------------------
Phone : Nexus 4
OS :
- KitKat 4.4.4 stock
- Xposed: 58(app_process); 54(bridge)
- SU: SuperSU
- no custom recovery
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

[Q] Pass variable from one class to another.

Hi, I'm doing an application which I need to send two variables encunetran in the following class:
public class MiLocationListener implements LocationListener{
public void onLocationChanged(Location loc){
if (loc != null) {
double lat = loc.getLatitude();
double lon = loc.getLongitude();
The lat and lon variable, I must send by post to the HttpHandler class
//AÑADIR PARAMETERS
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("latitud",lat)); // no reconoce lat ni lon
params.add(new BasicNameValuePair("longitud",lon)); // no reconoce lat ni lon
I should add code to take me the value of those variables?
I hope your help, I need it fast.
greetings
Try using shared prefs to save the two values
Or why dont you let your httphandler class implement locationlistener?
---------------------------------
Phone : Nexus 4
OS :
- KitKat 4.4.4 stock
- Xposed: 58(app_process); 54(bridge)
- SU: SuperSU
- no custom recovery
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

actionbar icons add on orientation change

Hey guys,
am using the actionbar in my application. when rotating the device, one of them is added right next to the first instance of it. performing multiple orientation results in having a bunch of these icons right next to each other.
Do you might know why?
I'm using the navigation drawer and used the official tutorial to do that and a base activity to spread it accross my application. Only the visible icon is multiplied, so none of the ones hidden.
If any additional information is needed, let me know asap! I will post it but I am not sure what it might be, thus not doing it right now.
Bests,
mcmardy
Well what i would do, i would create a different menu.xml for landscape mode which contains one item more than the other one
---------------------------------
Phone : Nexus 4
OS :
- KitKat 4.4.4 stock
- Xposed: 58(app_process); 54(bridge)
- SU: SuperSU
- no custom recovery
---------------------------------
4d 61 73 72 65 70 75 73 20 66 74 77
Gesendet von Tapatalk

Categories

Resources