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
zeekner
Jul 14, 2007

Doctor w-rw-rw- posted:

:frogsiren: :frogsiren: HOLY loving poo poo :frogsiren: :frogsiren:

https://github.com/jfeinstein10/SlidingMenu

Compile the example and try it out, or install it from the App Store: https://play.google.com/store/apps/details?id=com.slidingmenu.example

This actually works.
Amazingly well, in fact.
Even on 2.1.

As an Android developer I can't understate just how much this library will improve my quality of life. Dunno if anyone else is as thrilled by the existence of this library as I am.

God drat, I wish I knew about this a few weeks ago. This is going in Awful, gonna throw out the split-screen code I just barely added.

Adbot
ADBOT LOVES YOU

MrPablo
Mar 21, 2003

Doctor w-rw-rw- posted:

:frogsiren: :frogsiren: HOLY loving poo poo :frogsiren: :frogsiren:

https://github.com/jfeinstein10/SlidingMenu

Compile the example and try it out, or install it from the App Store: https://play.google.com/store/apps/details?id=com.slidingmenu.example

This actually works.
Amazingly well, in fact.
Even on 2.1.

As an Android developer I can't understate just how much this library will improve my quality of life. Dunno if anyone else is as thrilled by the existence of this library as I am.

This is fantastic. My only gripe is that the documentation doesn't seem to explicitly define the what above and below mean (that is which view is the sidebar and which is the main content). It's clear from the view attribute explanations, but I had to scroll down and stare at them for a second before it clicked.

TheReverend
Jun 21, 2005

Anybody going to AnDevConIV in San Francisco next week? :rory: :tinsley:

Doctor w-rw-rw-
Jun 24, 2008

TheReverend posted:

Anybody going to AnDevConIV in San Francisco next week? :rory: :tinsley:

I would if only I weren't considering completely abandoning my career in Android development in a couple of months. :(

Sab669
Sep 24, 2009

Doctor w-rw-rw- posted:

I would if only I weren't considering completely abandoning my career in Android development in a couple of months. :(

As someone whose been wanting to get into it, may I ask why that is?

Sereri
Sep 30, 2008

awwwrigami

A few reasons I can think of right now (there are probably a lot more)

Device fragmentation is high (which can lead to bugs on some devices but not others, so you should test on a few), as is supposedly piracy. Users sometimes void their warranty (they root) just to block ads. User reviews are terrible difficult though that might change with the g+ comments (probably not).

kitten smoothie
Dec 29, 2001

:siren: Actual MapFragment support from Google! :siren:

Doctor w-rw-rw-
Jun 24, 2008

Sab669 posted:

As someone whose been wanting to get into it, may I ask why that is?

Extreme bitterness, :qq:, and :smithicide: below.

:frogon:, you say? Okay, well...this will quickly descend into self-absorbed ranting so stop reading whenever you like. It's spoilered because I don't really want to make this thread discuss it any more than it has to, and I'm perfectly happy if people just skip over this.

Hardware manufacturers lie about what their devices are capable of, each handset maker has their own flavor of bugs to target (Samsung: lovely video players. HTC: theming incompatibilities. Motorola: stupid, difficult to notice bugs with cursors and setting activity orientations). Vanilla Android is nigh unusable, you've got to use the Android Compatibility Library and ActionBarSherlock at a minimum. ViewPagerIndicator, SlidingMenu, RoboGuice, and AQuery are optional, but may be good ideas. More if you want to do animation (NineOldAndroids). The Fragment*PagerAdapters handle fragments in viewpagers really poorly.

Google doesn't dogfood well and it really, really shows. The platform is structured very logically, and if you know what sucks and what doesn't you can do anything, but Android gives you 20 options and it's a challenge to pick the one that sucks the least. Since it's Java, it's easy to refactor, but at the same time you overcommit to structure and it's not really as flexible.

Building a mental model of exactly what is happening at any given point is really loving difficult because the activity lifecycle is awful, and it gets worse when you mix in Fragments. PROTIP: attaching and detaching your fragments doesn't necessarily correspond to onAttach and onDetach.

The entire process of developing for Android is one big slog against a horrible SDK where "working" and "doesn't look awful" on most devices is an astounding success. And what should be the official conference to learn about how to program the drat things has become a device-grubbing frenzy of opportunists. Was I pissed that I woke up an hour before signups opened (they opened at 6AM) and tried for the entire duration of the Google I/O ticket availability (30 minutes) just trying to get a ticket for work, only to have several of my friends sell off their free devices (for hundreds of dollars!) and not even loving attend? HELL loving YES.

I started as a generalist developer and then dove into iOS, which I found pretty enjoyable. Because I was reasonably multitalented - I can do ops, backend, a bit of HTML/CSS and just a little bit of JS - I was put on Android (and during this time, at no point was I even allowed to touch the backend code!). I grew bitter until I left that job, then contracted for a bit, which was quickly put to a stop by the guy I was contracting for screwing me hard (giving me half of what we agreed to and him insisting I was happy with that as far as he knew), followed by a job at a company I like with people I like, except for the fact that I was hired as an iOS developer, then, because we needed an Android app, put on Android again, and my boss essentially refuses to let me grow into other roles now - and to add unintentional insult to injury, multiple new hires are working on projects that I suggested we implement, and which I would be fantastically happy to work on. So instead I'm stuck working on a platform I don't love, and my will to care about the app and its users has finally been exhausted, I've stopped investing my mind into really working out why some bugs happen or how best to approach problems, and I find that awful because I really, really want to care. My enthusiasm as a whole for programming has gradually reduced to the point where despite the fact that I've been programming and aiming to work in Silicon Valley (which is where I work) since I was 5 (that's 19 years), I don't find the idea of leaving it completely unpalatable, though the money's too good and I'm too competent to really ever leave programming for good.

Android is not a platform you want to work on if you value your sanity. In ten years' time - hell, five years' time, even - it will be COBOL: old, hard to grok, and only a few bitter crusties who know the system too well and are too valuable to ever stop will remain. Android's flavor of Java will never be upgraded to Oracle's, period. There simply is no way barring a massive reconciliation between Google and Oracle and a sweetheart deal that Larry Ellison would never offer.

Though I get recruiters pestering me multiple times per week, it's always to become an Android developer somewhere else. Well, compared to my employer, most other companies seem full of poo poo, because well, I do love my company. But I've had it up to HERE with all the bullshit that Android entails and I'm never going to escape it unless I draw a line somewhere and make plans to rebuild my career doing something else.

So if you want to gently caress over your career, try doing Android full-time.
If you want to go nuts over a half-baked framework, try doing Android full-time.
If you want to bang your head against the desk because you just spent three months writing something unusable because a small detail makes it impossible to do something right, try doing Android full-time.
If you want to risk driving yourself into depression because you feel like you're constantly hitting dead-ends and wasting time, try doing Android full-time.

If you don't want to risk any of that, stay the gently caress away!

zeekner
Jul 14, 2007


This man speaks truth.

I've lost pretty much all the respect I had for Google over the last two years. Even as they slowly catch up, they still fail to fix many fundamental issues and then introduce new issues on top. Then you get into API fragmentation and OEM fuckery :smithicide:

Doctor w-rw-rw-
Jun 24, 2008
Oops, my rant mode got engaged. Since this post is about Android problems rather than why Android is a soul-sucking abyss, it's not spoilered:
-----

Oh, and Google totally pushed GoogleTV and made a bunch of people invest in developing apps for it only for it to totally flop. Its saving grace is that it's mostly compatible with Android. Mostly, because, well, it *is* Android, but a couple of things don't work exactly like you'd expect.

I mean, they didn't even have HLS on launch for video streaming for GoogleTV, changed what the ActionBar even was multiple times during development, had UI guidelines that weren't particularly great, told us to fix a bug that Google themselves had no clue how to fix, and their freaking Android Market app, on launch, filtered out ALL applications because it was developed against a newer version of Android than the GoogleTV ran on at the time.

At least they had the good sense to pull the Nexus Q before it launched. A friend (one of those who went for the swag) showed it to me. It basically didn't work. It was clearly trying to be AirPlay and couldn't even do that.

Not to mention, even after release, the Xoom and the Nexus 7, which as first-class devices ostensibly have first-class support for video playback, are prone to just black-screening when playing high-quality HLS streams with encryption. Also, although I should have known better, running two video views on some devices works while it breaks on others. Even on devices which are greater than version 2.3, meaning they use StageFright rather than godawful OpenCore (note: Samsung devices of particular versions will actually lie and say StageFright is enabled and then use OpenCore).

Google's EasyTracker addon to the Google Analytics library is easily the single biggest source of application crashes in my app. Don't use it, just use the analytics library directly.

And it's taken how many years for Google to get its head out of its rear end and finally realize the development process is broken and switch from Ant to Gradle? That their own set of Android library projects is just a workaround for forgetting to account for dependency management in Java, the ecosystem of a billion jars, and that it integrates not at all with them?

Oh, and Andy Rubin firmly believing in the lack of a distinction between a mobile device and tablet devices, thus leaving every developer to decide on the line themselves. Consistency? Who needs that? Got expectations? You're on your own!

So yeah. I could literally find things to rant on for hours.

TheReverend
Jun 21, 2005

If it makes you feel better I spend 90 percent of my time making and maintaining a windows mobile 6 app.

Doctor w-rw-rw-
Jun 24, 2008

TheReverend posted:

If it makes you feel better I spend 90 percent of my time making and maintaining a windows mobile 6 app.

*wince* How has the platform aged? Got any history Android can either learn from or doom itself to repeat (depending on your preference)?

Glimm
Jul 27, 2005

Time is only gonna pass you by

This is pretty cool:

http://www.androidviews.net/

Lots of different helpful views/libraries to use in your own projects.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Doctor w-rw-rw- posted:

Building a mental model of exactly what is happening at any given point is really loving difficult because the activity lifecycle is awful, and it gets worse when you mix in Fragments. PROTIP: attaching and detaching your fragments doesn't necessarily correspond to onAttach and onDetach.

Yes to this!

Thom Yorke raps
Nov 2, 2004


This seems suited to the current rants:
I'm trying to use the Google Maps API for Android. I ran this command:
code:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
And entered it plus my package name at the right place in the APIs console. Formatted like so:
SHA1;com.company.project

Got an API key. Put it into a layout definition like so:
code:
<com.google.android.maps.MapView
                android:id="@+id/walk_list_map"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:enabled="true"
                android:clickable="true"
                android:apiKey="APIKEY-HERE"
                />
And extended MapActivity in the enclosing Activity. Added this to my AndroidManifest.xml:
nested under manifest:
code:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <permission
            android:name="com.company.projectname.permission.MAPS_RECEIVE"
            android:protectionLevel="signature"/>
    <uses-permission android:name="com.company.projectname.permission.MAPS_RECEIVE"/>
    <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true"/>
nested under application:
code:
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="APIKEY-here"/>
        <uses-library android:required="true" android:name="com.google.android.maps" />
And every time I load my view that has a map in it, I get IOExceptions received 3 response from server, which when I googled means I have an incorrect API key.

I have explicitly set IntelliJ to use the ~/.android/debug.keystore for its cert, I have deleted debug.keystore and regenerated it and used that to make another key, that still didn't work. Running out of things to try, anyone have any thoughts on where I'm going wrong?

zeekner
Jul 14, 2007

Ranma posted:

This seems suited to the current rants:
I'm trying to use the Google Maps API for Android.

That looks like you hit every point, but last time I used the Maps API it was with v1 and they didn't require the package name to sign up. I can't tell what's wrong there.

e: Can you try to generate a normal signing key, authorize it, and build the final app with it?

jkyuusai
Jun 26, 2008

homegrown man milk
Tutorial Site Review:

So I've been using the tutorials on this site:

http://mobile.tutsplus.com/category/tutorials/android/

(as well as the ones found in the OP) for muddling through various bits of the Android platform over the past couple of weeks. The site above is good in the sense that it sometimes offers a more fleshed out description of what's going on in a particular piece of code versus say, Vogella's material. However, it's become apparent as I've gone through more and more of their material that the error rate in their code examples is kinda high. And not just silly dangling semicolons, but actual poo poo that the developer guide explicitly tells you not to do. I was clued into a lot of this by just reading the comments on a given tutorial. In most of the cases, the original authors responded and confirmed the errors. Unfortunately, their solution was to fix the linked source code, but not the erroneous code in the actual tutorial. :psyduck:

So, good descriptions, but beware the code examples, especially if they're not matching up with something you saw elsewhere.

Doctor w-rw-rw-
Jun 24, 2008
^ We should probably update the op sometime soon. Which tutorials have you found the most useful, and for what?

Found a neat library that seems to work well and plays nicely with SlidingMenu: DragSortListView. If you've ever wanted a list of items with drag-to-reorder, today is your lucky day. Its API seems to be sensible, too.

try out the demo on google play.

jkyuusai
Jun 26, 2008

homegrown man milk

Doctor w-rw-rw- posted:

^ We should probably update the op sometime soon. Which tutorials have you found the most useful, and for what?


There's more, but recently, these have seen the most use.

VG - Vogella
MT - mobile.tutsplus

Intro to Intents:
VG: http://www.vogella.com/articles/AndroidIntent/article.html

Intro to Fragments:
MT: http://mobile.tutsplus.com/tutorials/android/android-sdk_fragments/
VG: http://www.vogella.com/articles/Android/article.html#fragments

Making Fragments Backwards Compatible:
MT: http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/

Implementing Content Providers:
MT: http://mobile.tutsplus.com/tutorials/android/android-sdk_content-providers/ (ignore the use of managequery, just skip to the next tutorial when you hit that section)
VG: http://www.vogella.com/articles/AndroidSQLite/article.html

and the next in the same series

Accessing Content Providers, The Right Way:
MT: http://mobile.tutsplus.com/tutorials/android/android-sdk_loading-data_cursorloader/

Confusingly, both sets of tutorials sometimes seem to like to initially implement things using deprecated methods or in just plain bad ways. They try to justify it by saying that doing so simplifies things and should help you pick up the material faster. I always felt like it just made things worse because I was always afraid of picking up bad coding practices and wasn't sure what I could trust to be right. Thankfully, they usually at least tell you when they're doing that. If in doubt, Google it. 99% of the time, someone has already asked about it on SO.

edit:

Additionally:

An Explanation of Loaders and Why They're Our Friends (Read this after going through the content provider material)
http://www.androiddesignpatterns.com/2012/07/loaders-and-loadermanager-background.html

edit 2: Actually, I just skimmed the blog in the link above and it looks like it has a decent amount of good content.

jkyuusai fucked around with this message at 19:45 on Dec 11, 2012

Glimm
Jul 27, 2005

Time is only gonna pass you by


I lazily linked to this post from the OP and added Drag-Sort-ListView to the list of useful libraries.

Doctor w-rw-rw-
Jun 24, 2008

Glimm posted:

I lazily linked to this post from the OP and added Drag-Sort-ListView to the list of useful libraries.

Neat, thanks. Mind adding the link to SlidingMenu? It's mentioned in the same line as DSLV but not as its own bullet.

Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

Neat, thanks. Mind adding the link to SlidingMenu? It's mentioned in the same line as DSLV but not as its own bullet.

Oh oops, I thought I had added that awhile ago!

Gimbal_Machine
May 11, 2005
Bite me euler angles.

Doctor w-rw-rw- posted:

Oops, my rant mode got engaged.

I hear ya. I wouldn't say its career ending and I even enjoy it some days. I've officially been working on android full time for 3 years now.

The constant chorus of 'look at the source code' is a complete and utter joke. The source code is incomprehensible in many spots, using terrible package level linking, hidden and non-accessible methods, and providing non-extensible base implementations. This coupled with fairly sloppy coding standards just leads to serious direction setting issues, which you mention.

Pretty much everything requires special treatment. Device differences, OS level differences, manufacturer differences all add up to serious trouble.

OTOH, I don't think Android development is career ending. We get recruited all the time and the coding practices/debugging/hacking/profiling stuff is transitive to other languages.

I actually like how hard it is most of the time. I don't know that I agree with the sentiment that the SDK works against you. I really like ant, so thats a non-issue for me. Languages are languages. Libraries suck. You make lots of good points. There are just some things you kinda have to act like teflon about (gently caress senseui)

As far as recommended libraries, i've really enjoyed using ORMLite http://ormlite.com/ which, in my opinion, is much more usable then the ContentProvider framework Google proposes.

Doctor w-rw-rw-
Jun 24, 2008

Gimbal_Machine posted:

I hear ya. I wouldn't say its career ending and I even enjoy it some days. I've officially been working on android full time for 3 years now.

The constant chorus of 'look at the source code' is a complete and utter joke. The source code is incomprehensible in many spots, using terrible package level linking, hidden and non-accessible methods, and providing non-extensible base implementations. This coupled with fairly sloppy coding standards just leads to serious direction setting issues, which you mention.

Pretty much everything requires special treatment. Device differences, OS level differences, manufacturer differences all add up to serious trouble.

OTOH, I don't think Android development is career ending. We get recruited all the time and the coding practices/debugging/hacking/profiling stuff is transitive to other languages.

I actually like how hard it is most of the time. I don't know that I agree with the sentiment that the SDK works against you. I really like ant, so thats a non-issue for me. Languages are languages. Libraries suck. You make lots of good points. There are just some things you kinda have to act like teflon about (gently caress senseui)

As far as recommended libraries, i've really enjoyed using ORMLite http://ormlite.com/ which, in my opinion, is much more usable then the ContentProvider framework Google proposes.

It's career ending if Android was supposed to be a 1-or-2 month side project that you really didn't want to do in the first place, but did because you were the most qualified at a small company you liked -- then ended up doing for two years, neglecting your other skills and passions, hating yourself the whole time. My situation isn't common I'm sure. It's gotten to the point where I've stopped caring about my work and about programming, even though I've been doing it for 80%+ of my life - and I'm not even 25 yet.

Agreed on the other parts though.

Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

It's career ending if Android was supposed to be a 1-or-2 month side project that you really didn't want to do in the first place, but did because you were the most qualified at a small company you liked -- then ended up doing for two years, neglecting your other skills and passions, hating yourself the whole time. My situation isn't common I'm sure. It's gotten to the point where I've stopped caring about my work and about programming, even though I've been doing it for 80%+ of my life - and I'm not even 25 yet.

Agreed on the other parts though.

That really sucks :( I find myself in a bit of the opposite situation (I mostly work on iOS), though I don't have such an extreme distaste to iOS development as you have built up to Android. I wish I had more time on the side to work on Android stuff, c'est la vie.

In other news, this looks like a handy project:
https://github.com/cesarramirez/ADG-Android_Drawable_Generator

quote:

This is a tool that allows for the automatic creation of drawables resources for the different screen densities in an Android projects.

Uses perl and Imagemagick to do its work. Looks neat.

jkyuusai
Jun 26, 2008

homegrown man milk
edit: May have jumped the gun on this question/rant. Will do some more research first. Sorry guys! :downs:

Okay, this is dumb. Anyone been successful invoking the camera from an app and storing the resulting (full size!) photo in their app's data directory?

It seems like there's a stupid number of different approaches, and so far all the ones I've tried have crashed and burned.

edit2: Okay, I figured it out.

I was trying to start the camera from an intent inside my app, capture an image, and save it to a directory inside my app. In testing, I was able to get to the point of hitting the button to confirm an image to save, but then the camera would just sit there. After canceling out of the camera, it would return to the app, but the image wouldn't display. Upon checking out the directory, I would find an empty image file where the picture should have saved.

The issue was that when I was creating the file to be used as part of the MediaStore.ACTION_IMAGE_CAPTURE intent, the file's mode by default is set to MODE_PRIVATE which makes the file only editable by the originating application. So, when the camera would take a picture and try to save it, it would silently fail because it didn't have rights to write to the file URI I'd provided it. By overriding this and setting it to MODE_WORLD_WRITEABLE, the camera now had rights to write to the file and everything worked like I expected. After reading some more upon encountering this issue, I'm surprised setting that mode is all it took to allow the camera to write there, since it seems the app directories are supposed to be locked down pretty tight.

My reasoning for saving images to the app directory is that there's no real need (that we can see) at this time to display them as part of the user's gallery, and we also figure a user probably wouldn't WANT them to be shown there in most use cases. Saving them here keeps them out of the gallery, and also lets us have an easier time of managing disk space.

jkyuusai fucked around with this message at 16:33 on Dec 20, 2012

Glimm
Jul 27, 2005

Time is only gonna pass you by

IntelliJ for personal use is on sale right now, $50 (normally $200):
http://www.jetbrains.com/specials/index.jsp

I also picked up PyCharm ($25) though I typically use Vim for Python stuff, as I buggered my autocomplete settings for Python last weekend and can't be arsed to fix it; I've never used PyCharm - hope it doesn't suck. IntelliJ however I think is pretty awesome and if you hate Eclipse maybe give it a shot (there is a free Community Edition as well).

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Glimm posted:

I also picked up PyCharm ($25) though I typically use Vim for Python stuff, as I buggered my autocomplete settings for Python last weekend and can't be arsed to fix it; I've never used PyCharm - hope it doesn't suck. IntelliJ however I think is pretty awesome and if you hate Eclipse maybe give it a shot (there is a free Community Edition as well).

You might want to ask for a refund on PyCharm if you bought IntelliJ. All of the features of PyCharm are actually in the Python plugin that comes with IntelliJ Ultimate.

Glimm
Jul 27, 2005

Time is only gonna pass you by

ultramiraculous posted:

You might want to ask for a refund on PyCharm if you bought IntelliJ. All of the features of PyCharm are actually in the Python plugin that comes with IntelliJ Ultimate.

Oh dear, thanks for the heads up!

Thom Yorke raps
Nov 2, 2004


If I have a service, and inside this service I start multiple threads, is it possible for these threads to be killed by the OS to free up memory, WITHOUT the Service also getting killed?

pigdog
Apr 23, 2004

by Smythe

Glimm posted:

IntelliJ for personal use is on sale right now, $50 (normally $200):
http://www.jetbrains.com/specials/index.jsp

Thanks for this, I never would have known that if I didn't skim over this thread. Hooray for IDEA Ultimate Edition!

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
edit wrong thread.

Doctor w-rw-rw-
Jun 24, 2008

Ranma posted:

If I have a service, and inside this service I start multiple threads, is it possible for these threads to be killed by the OS to free up memory, WITHOUT the Service also getting killed?

If its under enough pressure to kill the threads it'll probably be under enough pressure to kill the service? My preferred pattern for using threads, if you must, is using executor services. Shutdown on stop, start on start. It's a bit more nuanced than that but it worked well. What are you trying to do, exactly?

5436
Jul 11, 2003

by astral
Which IDE do people generally prefer? Eclipse or IntelliJ IDEA?

Thom Yorke raps
Nov 2, 2004


5436 posted:

Which IDE do people generally prefer? Eclipse or IntelliJ IDEA?

I vastly prefer IntelliJ, I think the autocomplete is much better. Not a big fan of their 12.0 release though, the keyboard keeps freezing and requiring me to click somewhere with the mouse to fix it.

Doctor w-rw-rw- posted:

If its under enough pressure to kill the threads it'll probably be under enough pressure to kill the service? My preferred pattern for using threads, if you must, is using executor services. Shutdown on stop, start on start. It's a bit more nuanced than that but it worked well. What are you trying to do, exactly?
I have http PUT requests that cannot be lost. Every time one is generated, I shove it in a SQLite database and send a broadcast to my request runner service. That starts a thread to run all the pending requests in the database. It does this by loading all the requests with SYNCHRONIZED=0, then setting SYNCHRONIZED=1 for each request. If a request fails, it sets SYNCHRONIZED=0. If it succeeds, SYNCHRONIZED=2. But if the thread were to get killed, SYNCHRONIZED would remain at 1 until the service is killed and restarted, at which point it sets all of the requests with SYNCHRONIZED=1 to SYNCHRONIZED=0.

jkyuusai
Jun 26, 2008

homegrown man milk

5436 posted:

Which IDE do people generally prefer? Eclipse or IntelliJ IDEA?

My work uses Eclipse, so that's what I'm familiar with, but I bought IntelliJ in the sale and am planning to give it a go. I'll report back once I've had some time to try it.

5436
Jul 11, 2003

by astral
I couldn't get the SDK up and running on IntelliJ so I went back to Eclipse. I guess it'll be easier when I go to my Ubuntu box.

Doctor w-rw-rw-
Jun 24, 2008

Ranma posted:

I have http PUT requests that cannot be lost. Every time one is generated, I shove it in a SQLite database and send a broadcast to my request runner service. That starts a thread to run all the pending requests in the database. It does this by loading all the requests with SYNCHRONIZED=0, then setting SYNCHRONIZED=1 for each request. If a request fails, it sets SYNCHRONIZED=0. If it succeeds, SYNCHRONIZED=2. But if the thread were to get killed, SYNCHRONIZED would remain at 1 until the service is killed and restarted, at which point it sets all of the requests with SYNCHRONIZED=1 to SYNCHRONIZED=0.

My first instinct would be to use IntentService, and see how that works for you (but no parallelism). My second reaction would be to use an ExecutorService with a threadpool. I don't think you can have any strong assurance that the service won't be killed, mainly because Android is poo poo and even when I did implement a service that should have been started from app launch and should never have died, it would still show NPEs due to not existing on some platforms.

amishpurple
Jul 21, 2006

I'm not insane, I'm just not user-friendly!
Can anyone better explain the purpose of using putExtra() in this section of the tutorial? I just don't understand what it does and subsequently why it's needed.

Adbot
ADBOT LOVES YOU

zeekner
Jul 14, 2007

amishpurple posted:

Can anyone better explain the purpose of using putExtra() in this section of the tutorial? I just don't understand what it does and subsequently why it's needed.

It's explained further down in that example, when they pull the message from the intent.

code:
Intent intent = getIntent();
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
Extras are just a convenient method for sending some data to the new activity, typically to give it some starting context. You can pass primitives and Parcelable objects.

Don't rely on this to send everything; if you have a lot of data that you need to use throughout your app, look into Services or ContentProviders.

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