Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Kenishi
Nov 18, 2010
I'm trying to figure out if I'm going to run into problems down the road in my app.

In my app I have a class called ServerListManager. Basically its just a global dispatch class that keeps a list of server sockets synced across the app. When a socket changes state or a user adds/removes a server from the "paired" list, the Manager will remove or update the Socket/IP from the SharedPreference file and dispatch an event to all registered listeners.

Because I've built this pretty much waterfall style and have no test bed in place to test out the networking :smithicide:, I'm not sure what will happen when sockets start changing state. In particular I recently realized that I couldn't just create a thread and fire off an event that would update my ListAdapter (Can't edit views from threads outside the UI thread). From the user side, such as when the user adds/removes an IP from the list, the Adapter will trigger an update event which passes along a Context that I can cast back to an Activity (I pass around getActivity() as the context).

The networking side however is tied to a service which spawns a new thread and passes the Service into the thread as the Context. Am I understanding the docs right and that I'm still okay since Services exists inside the main app's thread? Or will I get casting exceptions or some other exception when the network thread tries to cast the Service's context/activity and call runOnUiThread()?

Hope that makes sense.

Adbot
ADBOT LOVES YOU

Fluue
Jan 2, 2008

kitten smoothie posted:

In Results' onCreate method:

This isn't the resource ID for a ListView. It's not even a resource ID for a view at all, which is why it's returning null. That is why your list.setAdapter call is blowing up.

code:
list = (ListView) findViewById(R.layout.list_generated_pokemon);

I have a custom adapter setup because I have a defined row layout (Therefore I have a listview and a row xml file)

I am using a (probably lovely) adapter called LazyAdapter from a tutorial site just so I can get a hang of using an adapter. If I got my resource IDs correct, the adapter should just take in ArrayList<HashMap<string, string>> right?

Relevant code, including my views: https://gist.github.com/verkaufer/578af362176847e29970

Googling for transferring an ArrayList<HashMap<>> data type into a ListView has been fruitless so far. If there's a tutorial I'm overlooking (and I've looked at Vogella), please direct me to it.

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?

Fluue posted:

I have a custom adapter setup because I have a defined row layout (Therefore I have a listview and a row xml file)

I am using a (probably lovely) adapter called LazyAdapter from a tutorial site just so I can get a hang of using an adapter. If I got my resource IDs correct, the adapter should just take in ArrayList<HashMap<string, string>> right?

Relevant code, including my views: https://gist.github.com/verkaufer/578af362176847e29970

Googling for transferring an ArrayList<HashMap<>> data type into a ListView has been fruitless so far. If there's a tutorial I'm overlooking (and I've looked at Vogella), please direct me to it.

Here's how I setup a ListView for an app of mine (snipped for relevant parts):
Java code:
	ArrayAdapter<Spanned> adapter = null;
	ArrayList<Spanned> spannedList = new ArrayList<Spanned>();
	//snip
	Quake q = new Quake(getIntent().getStringExtra("Quake" + i));
	//snip loops and poo poo
	//adapter = new ArrayAdapter<Quake>(this,
	//        android.R.layout.simple_list_item_1, quakeList);
	spannedList.add(q.toSpanned());
	adapter = new ArrayAdapter<Spanned>(this,
	            android.R.layout.simple_list_item_1, spannedList);
	setListAdapter(adapter);
I did this only because I needed to color the text in the ListView via html encoding. q.Spanned() returns type Spanned. You can just set the ArrayAdapter<whateverClass> and skip the spannedList stuff, too. This is how I used to have it (ArrayAdapter<Quake> and ArrayList<Quake>) prior to this implementation. It's slightly weird like this; my layout is actually called "@android:id/list" yet it gets referenced by simple_list_item_1. Some weirdness with Android.

Evil_Greven fucked around with this message at 21:47 on May 14, 2014

Fluue
Jan 2, 2008

Evil_Greven posted:

Here's how I setup a ListView for an app of mine (snipped for relevant parts):
Java code:
	ArrayAdapter<Spanned> adapter = null;
	ArrayList<Spanned> spannedList = new ArrayList<Spanned>();
	//snip
	Quake q = new Quake(getIntent().getStringExtra("Quake" + i));
	//snip loops and poo poo
	//adapter = new ArrayAdapter<Quake>(this,
	//        android.R.layout.simple_list_item_1, quakeList);
	spannedList.add(q.toSpanned());
	adapter = new ArrayAdapter<Spanned>(this,
	            android.R.layout.simple_list_item_1, spannedList);
	setListAdapter(adapter);
I did this only because I needed to color the text in the ListView via html encoding. q.Spanned() returns type Spanned. You can just set the ArrayAdapter<whateverClass> and skip the spannedList stuff, too. This is how I used to have it (ArrayAdapter<Quake> and ArrayList<Quake>) prior to this implementation. It's slightly weird like this; my layout is actually called "@android:id/list" yet it gets referenced by simple_list_item_1. Some weirdness with Android.
So you're skipping a custom implementation and just using ArrayAdapter?

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?

Fluue posted:

So you're skipping a custom implementation and just using ArrayAdapter?
In that example, yeah - it's just a line of text for the Quake summary; I don't need a custom implementation for that. What you're doing is more advanced than that - but that's beside the point.

You're going about getting the list reference the wrong way, or at least atypically.

As far as I'm aware the typical use is:
1) you need to make your activity extend ListActivity rather than Activity; I missed this on your code before.
2) you are limited to one list, called (as previously) "@android:id/list" in the layout XML.
3) you can then use setListAdapter(adapter); to... yeah.

Try changing just these bits of your activity first, rather than your custom adapter.

e: Of course, before that, you should fix what kitten smoothie mentioned if you haven't:
R.layout.list_generated_pokemon points to your layout file
R.id.list_row is the list itself

Evil_Greven fucked around with this message at 22:51 on May 14, 2014

zeekner
Jul 14, 2007

Evil_Greven posted:

In that example, yeah - it's just a line of text for the Quake summary; I don't need a custom implementation for that. What you're doing is more advanced than that - but that's beside the point.

You're going about getting the list reference the wrong way, or at least atypically.

As far as I'm aware the typical use is:
1) you need to make your activity extend ListActivity rather than Activity; I missed this on your code before.
2) you are limited to one list, called (as previously) "@android:id/list" in the layout XML.
3) you can then use setListAdapter(adapter); to... yeah.

Try changing just these bits of your activity first, rather than your custom adapter.

There's little reason to extend ListActivity, all it does is grab a reference to the listview and provide helpers for adapter functions. Everything it does can be replicated with a simple findViewById and setting the adapter directly.

ListView itself is pretty simple, and ListActivity only automates the easiest part. The real annoying complexity is in the adapter, and doubly so if you want multiple item types and ViewHolders for more efficient recycling. I ended up creating a custom adapter that handled most of that annoying stuff automatically, but it still requires a little work defining item layouts and functionality.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I'm working on an app right now, and I'm often switching between identical development environments on my desktop and my laptop depending on when and where I want to work. Is it possible to use a single certificate on both machines to sign debug builds so that I don't have to always uninstall/reinstall my app when the certs don't match?

zeekner
Jul 14, 2007

If you are using gradle, just use your release key to sign the debug build. Then you'll never get the inconsistent signing error.
code:
    buildTypes {

        debug {
            runProguard false
            signingConfig signingConfigs.release
        }
     }
Otherwise, you can copy the debug.keystore from one computer to another. It's usually in ~/.android/.

jkyuusai
Jun 26, 2008

homegrown man milk

Karthe posted:

Is it possible to use a single certificate on both machines to sign debug builds so that I don't have to always uninstall/reinstall my app when the certs don't match?

Yep!

efb;

Fluue
Jan 2, 2008
So my app got suspended from the market after submitting it. It's apparently because of Impersonation and Intellectual Property infringement (for Pokemon). When I look up "Pokemon" in the Play Store I get at least 20 other apps that use the Pokeball, the name, or a combination of both. I am definitely not trying to pass off my app as official.. so what's Google's beef?

Has anyone had success appealing an app suspension?

kitten smoothie
Dec 29, 2001

From the stories out there on the blogs, appeal requests are nearly immediately denied, and resubmitting the app will be another strike against you. Three strikes and you are banned for life from the store.
They warn you not to create additional Google accounts and resubmit because those are subject to banning on sight. With the kind of data they have, they probably have lots of analysis procedures for identifying accounts held by the same person.

Tunga
May 7, 2004

Grimey Drawer

Fluue posted:

When I look up "Pokemon" in the Play Store I get at least 20 other apps that use the Pokeball, the name, or a combination of both. I am definitely not trying to pass off my app as official.. so what's Google's beef?
What, exactly, does your app do?

Sereri
Sep 30, 2008

awwwrigami

kitten smoothie posted:

Three strikes and you are banned for life from the store.

According to what I've read this does not only apply to the developer side but they'll ban your entire Google account (mail, g+, play store purchases, etc). For life.

Fluue
Jan 2, 2008

Tunga posted:

What, exactly, does your app do?

It allows users to generate/display a team of 6 Pokémon. It's basically just an information app.. There are other Pokémon apps that have way more information and do more than mine. I'm not sure why it got banned.

It's basically an app implementation of this: http://wyncorporation.com/pokemon

Fluue fucked around with this message at 19:22 on May 18, 2014

Jarl
Nov 8, 2007

So what if I'm not for the ever offended?
I have a WebView with a WebChromeClient. When testing on a 4.2.2 or 4.3 device the WebChromeClient's onShowCustomView is invoked, when something wants to go full screen. However with 4.4.2 (devices Nexus 7 and Galaxy S4) it has worked with HTML 5 videos, but flash videos wanting to go full screen does not invoke onShowCustomView.

I haven't been able to find confirmation that there is a problem or a change somewhere between 4.3 and 4.4.2.

Anybody here who knows what's up?

Rothon
Jan 4, 2012

Jarl posted:

I have a WebView with a WebChromeClient. When testing on a 4.2.2 or 4.3 device the WebChromeClient's onShowCustomView is invoked, when something wants to go full screen. However with 4.4.2 (devices Nexus 7 and Galaxy S4) it has worked with HTML 5 videos, but flash videos wanting to go full screen does not invoke onShowCustomView.

I haven't been able to find confirmation that there is a problem or a change somewhere between 4.3 and 4.4.2.

Anybody here who knows what's up?

WebView is backed by Chrome in Android 4.4+: http://developer.android.com/guide/webapps/migrating.html

scanlonman
Feb 7, 2008

by R. Guyovich
Is there a guide for how to architect an Android application? I've seen people have one activity that controls many fragments, one activity for each fragment, and probably variations of both. What is the "right" behavior? How do fragments communicate with each other?

I can't find one set answer on what to do. Sadly Android doesn't easily conform to MVC :smith:

Doctor w-rw-rw-
Jun 24, 2008

scanlonman posted:

Is there a guide for how to architect an Android application? I've seen people have one activity that controls many fragments, one activity for each fragment, and probably variations of both. What is the "right" behavior? How do fragments communicate with each other?

I can't find one set answer on what to do. Sadly Android doesn't easily conform to MVC :smith:
I've done variations on both ways to do it and more, and there's no totally right answer.

For fragment communication, the way that is "anointed" is to pass interfaces around between fragments. Problem with that is that you've adopted the overhead of maintaining an interface from the outset, possibly before you even know what you're building. So I used to use (it's been a loooong time since I did Android) a weak reference to the owning activity instead, and call methods as necessary.

Other tips -
* Don't stack fragments if fragment state is important. Back-stack state restoration is unreliable (did they ever fix this?)
* When creating and launching a new activity, it's pretty convenient to stick the info you used to launch the activity in the intent. It's immutable and if your activity's state gets reset, it still has access to the intent used to make it and can reconstruct its original state pretty easily.
* If you're dealing with video views inside fragments, HERE BE DRAGONS. Video views have a lifecycle of their own. Dealing with activity and fragment lifecycles on top of that is scary.

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
How crazy am I for wanting to try and make a mobile game without using a game library? As in, I just use regular Android like with any other non-game app. I want to make a simple turn-based game, and while most games use Unity or the like, it seems a bit overkill for something as basic as what I have in mind.

Should I just quit bitching and learn to Unity?

Tunga
May 7, 2004

Grimey Drawer

Karthe posted:

How crazy am I for wanting to try and make a mobile game without using a game library?
If you don't need any 3D graphics or flashy animations then you should be able to do it with native stuff. Really depends what the UI is like. I've not personally used Unity but I was under the impression one of the main benefits is that it is cross-platform.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Karthe posted:

How crazy am I for wanting to try and make a mobile game without using a game library? As in, I just use regular Android like with any other non-game app. I want to make a simple turn-based game, and while most games use Unity or the like, it seems a bit overkill for something as basic as what I have in mind.

Should I just quit bitching and learn to Unity?

If you're going to make a simple game engine and you can represent your game state in standard views, not crazy at all. That said, you may well decide to at a minimum make your own surfaceview implementation, which lends itself towards you writing at least a minimal engine.

Claeaus
Mar 29, 2010
In my app I would like to have some backup functionality. So I was thinking of exporting/importing the SQLite database file.

However, so far I have managed to keep my app clean of any permissions and if possible would like to keep it this way. Is there a way to delegate this somehow through an Intent to a file manager or something what you can do with the camera and mail sending?

Claeaus fucked around with this message at 20:59 on Jun 6, 2014

Infomaniac
Jul 3, 2007
Support Cartographers Without Borders
You can write to internal storage with no permissions. I would just write a complete db dump as a csv every once in a while. You can always access the files you create from within your own app.

http://developer.android.com/training/basics/data-storage/files.html

You will have to do some extra stuff if you want to attach it to an email or something.

https://developer.android.com/training/secure-file-sharing/share-file.html

Claeaus
Mar 29, 2010

Infomaniac posted:

You can write to internal storage with no permissions. I would just write a complete db dump as a csv every once in a while. You can always access the files you create from within your own app.

http://developer.android.com/training/basics/data-storage/files.html

You will have to do some extra stuff if you want to attach it to an email or something.

https://developer.android.com/training/secure-file-sharing/share-file.html

Ah great! Also it seems that reading from external storage doesn't require any permissions for versions prior to 4.4. So I'm guessing with some fiddling around it should be possible. Thanks!

IAmKale
Jun 7, 2007

やらないか

Fun Shoe
Is there a way to disable the "swipe to bring up system bars" functionality in Kit-Kat's Immersive Mode? I'm trying to figure out some way of locking users into an app (a la "kiosk mode") without requiring root. Ideally I could enable Immersive Mode and then ignore the swipes down from the top or up from the bottom, but there doesn't appear to be an easy way to detect that (probably by design).

Edit: Nevermind, according to Roman Nurik it looks like the app isn't notified when those actions are performed.

IAmKale fucked around with this message at 19:32 on Jun 8, 2014

pr0metheus
Dec 5, 2010
How does Chrome implement full-screen scrolling? That is how does it animate the action bar to hide along with the finger?

I have made my own implementation that consists of putting action bar into overlay mode and then capturing y-delta of pixels that a list scrolls by. This seems to work well as the list doesn't have to be re-laid out, but I am wondering if there is a widget created for this or some other standard way.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
I have an idea for an app that I want to start developing, but it will definitely require server component because it involves sharing data between multiple users and those users being able to send each other notifications and such. I'm very comfortable with Java and I've got a enough practice at SQL for the purposes of this app. What I've never done, however, is any programming involving client-server communication. If anyone can point me at some resources or tutorials to get me started at figuring that bit out, I'd be grateful. My two big questions are:
* Without paying for hosting, how do I go about setting up some kind of server to code on and test against? For the purposes of development I think a server either running virtually on my PC or on a headless box on my home network would be fine, but I don't really know where to start in getting that set up.
* Where can I go to get more information about communication between Android apps and a remote server?

pr0metheus
Dec 5, 2010
Android has HTTP client that you can use, so look up tutorials on that. HTTP is what you most likely what to use, but if not you can also directly use sockets and that would be standard Java.

Gozinbulx
Feb 19, 2004
I'm trying to write a .sh script which will install an app. When i run the command "pm install *name of apk*.apk, it works fine. When I put that same line in a script, I get "failed: INVALID_URI", thats not the exact phrasing but something similar. Ive googled the poo poo out of that error and seen tons of questions and only a few answers, all of which say its some fundamental rom issue and to reflash the rom. That sounds crazy and not probable. Yes im doing this all in root. Ive tried changing permissions on all kinds of folders "/system, /data, /data/local, ect) and no dice.

Anyone have any experience which what Im trying to do? How do you install an apk from a script (not just terminal emulator)?

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Gozinbulx posted:

I'm trying to write a .sh script which will install an app. When i run the command "pm install *name of apk*.apk, it works fine. When I put that same line in a script, I get "failed: INVALID_URI", thats not the exact phrasing but something similar. Ive googled the poo poo out of that error and seen tons of questions and only a few answers, all of which say its some fundamental rom issue and to reflash the rom. That sounds crazy and not probable. Yes im doing this all in root. Ive tried changing permissions on all kinds of folders "/system, /data, /data/local, ect) and no dice.

Anyone have any experience which what Im trying to do? How do you install an apk from a script (not just terminal emulator)?

Is the script running in the same directory as the apk? If not, you need to give the entire \path\to\the.apk in the script.

Gozinbulx
Feb 19, 2004

LeftistMuslimObama posted:

Is the script running in the same directory as the apk? If not, you need to give the entire \path\to\the.apk in the script.

It is not, and I do indeed give the whole /path/to/apk.apk


Is this appropriate syntax? :

pm install /sdcard/temp/folder/target.apk

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Gozinbulx posted:

It is not, and I do indeed give the whole /path/to/apk.apk


Is this appropriate syntax? :

pm install /sdcard/temp/folder/target.apk

I'd think that would work, but try maybe /mt/sdcard/.../target.apk, judging from this link http://www.all-things-android.com/content/understanding-android-file-hierarchy
Also, does the script request elevated permissions at any point? I know on other flavors of *nix you'd need to sudo your install command.

Gozinbulx
Feb 19, 2004
I believe it does. The way I execute the script is in Terminal emulator, cd'ing over to to the directory, giving a quick 'su' command (the phone is rooted) and then going './scriptname.sh'

edit: Throwing an 'su' into the script just returns a [: not found, same for 'sudo'. Didn't think any of those would work but I just wanted to rule it out.

Gozinbulx fucked around with this message at 18:02 on Jun 11, 2014

Literally Elvis
Oct 21, 2013

So this thing is going on tomorrow, and I'm going back and forth on going. On the one hand, I'm certain I'd learn a lot, but on the other hand, it looks like they're expecting people good enough to create things quickly, and I'm nowhere near that adept at this stuff. Also, I have no loving clue what sort of functionality I'd like a watch or other wearable to have beyond just telling time, so even if i were knowledgeable enough to make something quickly, I wouldn't know what.

My gut tells me to just go, and worst comes to worst, not participate as much as maybe the organizers would like, but I wanted to see if people who are maybe familiar with these sort of events would advise against that or not.

zeekner
Jul 14, 2007

Literally Elvis posted:

So this thing is going on tomorrow, and I'm going back and forth on going. On the one hand, I'm certain I'd learn a lot, but on the other hand, it looks like they're expecting people good enough to create things quickly, and I'm nowhere near that adept at this stuff. Also, I have no loving clue what sort of functionality I'd like a watch or other wearable to have beyond just telling time, so even if i were knowledgeable enough to make something quickly, I wouldn't know what.

My gut tells me to just go, and worst comes to worst, not participate as much as maybe the organizers would like, but I wanted to see if people who are maybe familiar with these sort of events would advise against that or not.

They say you can collaborate with others, just go and at worst you can just jump in with someone else. These things aren't high pressure.

Thom Yorke raps
Nov 2, 2004


LeftistMuslimObama posted:

I have an idea for an app that I want to start developing, but it will definitely require server component because it involves sharing data between multiple users and those users being able to send each other notifications and such. I'm very comfortable with Java and I've got a enough practice at SQL for the purposes of this app. What I've never done, however, is any programming involving client-server communication. If anyone can point me at some resources or tutorials to get me started at figuring that bit out, I'd be grateful. My two big questions are:
* Without paying for hosting, how do I go about setting up some kind of server to code on and test against? For the purposes of development I think a server either running virtually on my PC or on a headless box on my home network would be fine, but I don't really know where to start in getting that set up.
* Where can I go to get more information about communication between Android apps and a remote server?

I would consider checking out some BaaS like CloudMine or Parse, then you can just use their APIs and not run a server yourself.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Ranma posted:

I would consider checking out some BaaS like CloudMine or Parse, then you can just use their APIs and not run a server yourself.

Honestly, I think it would be fun to diy it, I'm just having trouble getting Google to cooperate with my attempts to find any guides to get started.

Evil_Greven
Feb 20, 2007

Whadda I got to,
whadda I got to do
to wake ya up?

To shake ya up,
to break the structure up!?

LeftistMuslimObama posted:

I have an idea for an app that I want to start developing, but it will definitely require server component because it involves sharing data between multiple users and those users being able to send each other notifications and such. I'm very comfortable with Java and I've got a enough practice at SQL for the purposes of this app. What I've never done, however, is any programming involving client-server communication. If anyone can point me at some resources or tutorials to get me started at figuring that bit out, I'd be grateful. My two big questions are:
* Without paying for hosting, how do I go about setting up some kind of server to code on and test against? For the purposes of development I think a server either running virtually on my PC or on a headless box on my home network would be fine, but I don't really know where to start in getting that set up.
* Where can I go to get more information about communication between Android apps and a remote server?

1) Don't talk to your SQL directly from your Android app. Use a PHP (or some other equivalent) server-side interface. People can decrypt your .APK so... yeah.
2) Easiest way is probably through JSON and Apache HTTP calls. You'll need at least the Apache library installed (apache-mime4j-0.6.jar was what I used in this project).

I built a system back for my final college project that consisted of a full (if rough) user registration and management system with file I/O via Web and Android app. That code is a bit ugly due to time issues and the fact that none of the other three assholes on my team did anything (between the 3 of them, maybe 5% of the coding), but here's a bit more cleaned up code for an app that reads and parses a simple webpage for a different project:
code:
	private class DoPOST extends AsyncTask<String, Void, Boolean> {
		private static final String ADDR = "wichita.ogs.ou.edu";
		private static final String PORT = "80";
		String PAGE = "eq/index.html";
		Exception exception = null;
		String[] quakes;
		String update;
		
		DoPOST(String page){
			PAGE = page;
		}

		@Override
		protected Boolean doInBackground(String... arg0) {
			try{
				//Create the HTTP request
				HttpParams httpParameters = new BasicHttpParams();

				//Setup timeouts
				HttpConnectionParams.setConnectionTimeout(httpParameters, 15000);
				HttpConnectionParams.setSoTimeout(httpParameters, 15000);			

		        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

				HttpClient httpclient = new DefaultHttpClient(httpParameters);
			    HttpContext localContext = new BasicHttpContext();
				HttpPost httppost = new HttpPost("http://" + ADDR + ":" + PORT + "/" + PAGE);
				httppost.setEntity(mpEntity);

				HttpResponse response = httpclient.execute(httppost, localContext);
				HttpEntity entity = response.getEntity();

				String result = EntityUtils.toString(entity);
				update = result.substring(result.indexOf("Updated") + 8, result.indexOf(" UTC"));
				result = result.substring(result.indexOf("<tr><td>"), result.indexOf("</table>"));
				quakes = result.split("<tr><td>");

			} catch (Exception e) {
				Log.e("ClientServerDemo", "Error:", e);
				exception = e;
			}

			return true;
		}

		@Override
		protected void onPostExecute(Boolean valid){
			//Update the UI
			if(exception != null) {
	            Activity activity = (Activity)mContext;
	            if ( activity != null && activity.isFinishing() )
	                return;
	            AlertDialog.Builder abWarning = new AlertDialog.Builder(mContext);
		        abWarning.setMessage("Unable to connect through network.
		        \nAre you connected to the internet?").setPositiveButton("Retry", dialogClickListener)
		        		.setNegativeButton("Continue", dialogClickListener).show();

			} else {
				setupList(update, quakes);
			}
		}
...
		DoPOST mDoPOST;
		mDoPOST = new DoPOST("eq/index.html");
		mDoPOST.execute("");
Basically how I implemented it was by checking if the webpage was called using "mobile" as a parameter in the URL, with the server side implementation in PHP. If true, it would generate a JSON string as output, which the Android app would read and do what it needed to do. Otherwise, it generated a webpage as normal. You'll want to use some encryption as well for any information you don't want others to read.

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Is there a site or book that has some good example projects to build up my Android skills? The Google tutorials definitely explain the api well, but the I feel like I need to do a few projects that build up the complexity so I can get a better feel for how it all fits together. I've always sucked at just making up projects for myself when I'm not programming something I actually need.

Adbot
ADBOT LOVES YOU

kitten smoothie
Dec 29, 2001

LeftistMuslimObama posted:

Is there a site or book that has some good example projects to build up my Android skills? The Google tutorials definitely explain the api well, but the I feel like I need to do a few projects that build up the complexity so I can get a better feel for how it all fits together. I've always sucked at just making up projects for myself when I'm not programming something I actually need.

The Big Nerd Ranch book seems pretty good, I think. http://www.bignerdranch.com/we-write/android-programming

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply