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
Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

What is the least-ugly way of writing SQL for Android in Eclipse? Right now I'm putting each statement one-per-line in my strings.xml file like this:

XML code:
<string name="MicroJobsDatabase_onCreate">"
CREATE TABLE jobs (_id INTEGER PRIMARY KEY AUTOINCREMENT, employer_id INTEGER, title TEXT, [...]);
CREATE TABLE employers( _id INTEGER, employer_name TEXT, contact_name TEXT, website TEXT, [...]);
[...]
"</string>
and chopping the lines into an array of Java strings. However I'm pretty sure I will screw something up, either through mis-escaping something or misreading what I've written due to not using whitespace like I always have with SQL.

(code stolen from here)

Adbot
ADBOT LOVES YOU

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Doctor w-rw-rw- posted:

You could put your .sql files in the assets directory and write a class to load your SQL from that.

Does this involve writing like, half of a SQL lexical scanner? In the book I'm reading, the methods used to pass statements to SQLite (e.g. execSQL(String sql)) accept one statement at a time, so since I want to write .sql files with nice indentation and whitespace it seems I'd need to have a more complex tokenization process than my current scheme of String.split("\n").

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Zaldron posted:

Hi, I'm a newbie Android developer doing a project for college. It's coming along pretty nicely, except for the fact that it looks completely uninteresting. Could someone point me to some resources/guides/whatever I could use as a crash course on styling my text based Android 2.3 application?

There is a design section in the official docs, though I'm not sure if that's what you're looking for. I'm a newbie too and the Metrics and Grids page was enlightening, e.g.:

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

mugrim posted:

I did some VERY minor programming in high school (C++ class for like a year), would it be absolutely insane to try and learn how to make an Android App?

It depends on how complicated an app you want to make, and how much time and effort you're willing to invest. Do you want to make a 3D real-time game, and you've never studied higher-level math? Then you'll probably have a tough time. Do you want to make a fart noise app? Sure, go hog wild.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Zero The Hero posted:

Hey guys, looking for some advice here. I'm trying to do some type of persistent data storage in my app, [...] all I have is a LinearLayout with a series of CheckBoxes. I just need an efficient way to save the data, which is the only way a checklist is ever going to be useful.

SQLite, man.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Saying "I hate Obj-C and Java, but I like C#" is either really dumb or really incomplete. Dumb if you're referring to syntax itself, given their similarities; incomplete if you're really talking about standard libraries, runtimes, or other things.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

I'm working on this free "learn android coding" class and I cannot bring myself to copy/paste the example code they gave me for this one lesson. I know, it's just example code for a tutorial app and who gives a poo poo, but I can't bring myself to do it.

The lesson is "make your CursorLoader more efficient by using database projections!" Here is the diff for the example code but the relevant bit is this:

Java code:
private static final String[] FORECAST_COLUMNS = {
            // In this case the id needs to be fully qualified with a table name, since
            // the content provider joins the location & weather tables in the background
            // (both have an _id column)
            // On the one hand, that's annoying.  On the other, you can search the weather table
            // using the location set by the user, which is only in the Location table.
            // So the convenience is worth it.
            WeatherContract.WeatherEntry.TABLE_NAME + "." + WeatherContract.WeatherEntry._ID,
            WeatherContract.WeatherEntry.COLUMN_DATE,
            WeatherContract.WeatherEntry.COLUMN_SHORT_DESC,
            WeatherContract.WeatherEntry.COLUMN_MAX_TEMP,
            WeatherContract.WeatherEntry.COLUMN_MIN_TEMP,
            WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING,
            WeatherContract.WeatherEntry.COLUMN_WEATHER_ID,
            WeatherContract.LocationEntry.COLUMN_COORD_LAT,
            WeatherContract.LocationEntry.COLUMN_COORD_LONG
    };

    // These indices are tied to FORECAST_COLUMNS.  If FORECAST_COLUMNS changes, these
    // must change.
    static final int COL_WEATHER_ID = 0;
    static final int COL_WEATHER_DATE = 1;
    static final int COL_WEATHER_DESC = 2;
    static final int COL_WEATHER_MAX_TEMP = 3;
    static final int COL_WEATHER_MIN_TEMP = 4;
    static final int COL_LOCATION_SETTING = 5;
    static final int COL_WEATHER_CONDITION_ID = 6;
    static final int COL_COORD_LAT = 7;
    static final int COL_COORD_LONG = 8;
I just cannot deal with making this brittle "data structure" (if you can even call it that) where all these ints just sort of happen to correspond to some array over there. I know there is probably a really easy solution to this, but I'm blanking on it. Please remind me of the very obvious class or combo that does exactly what I'm looking for here :v:

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

nah the example app does use relations, and the SQLite/ContentProvider stuff is just in there to teach you it. also i know sql and relational algebra anyway so that part of it was EZ to learn

basically my question was just like "i'm sure there is a data structure class in the java standard library somewhere that basically solves this" but i'm still just grossing out that someone would suggest that gross brittle crap

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Splinter posted:

Where is the proper place to store API keys? Right now I just have it in the app code, but that means it'll be publicly viewable if I ever put the project on github, and also had the thought that it might be possible to decompile the APK to grab it.

For my spare time teach-yourself-Android projects, I keep Web service APIs in a separate XML resource file, and I put that filename in a .gitignore

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

kitten smoothie posted:

A slightly cleaner (at least because you're not ignoring an XML deep into your code tree) is to lean on Gradle tooling to do this. Edit your gradle.properties (which you .gitignore)

Then the Android Gradle plugin will create fields for you that you can use in your code; just say BuildConfig.TWITTER_API_KEY.

The only differences I see between this way and mine is that (1) I'm ignoring a different file and (2) the string reference in the code will be named a bit differently. Is it really considered "less clean" to ignore /app/src/main/res/values/totallysecret.xml versus doing the Gradle thing? My way still gives me fields to use in my code, the only difference is that instead of your BuildConfig.SECRETSQUIRREL I put on my robe and R.string.SECRETSQUIRREL hat.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

are you familiar with the relational algebra

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

relational algebra is the mathematical framework from which SQL is derived, yeah

to be honest, you being stumped on how to create features such as "have more than one tag per image" and "be notified when an image is deleted" leads me to suspect that you don't really have the most robust knowledge of relational data models. i apologize if that sounds pretty blunt but i say it in the hopes that it might save you a lot of banging your head against the wall. having a relationship such as "one image can have zero or more tags" is what you will find described in the literature as a "one to many" relationship, and it's one of the basic building blocks that a person is almost required to know in order to create a successful and well-functioning SQL database. my advice for you is to go read more about relational databases, and more specifically the topics of: data modeling, keys, triggers, and updates/deletes (specifically: updates and deletes that "cascade").

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

american watches default to hands at 10 and 2. french watches default to pencil-thin hands at 4 and 8 with an eyeroll complication. this might be your problem

joke answer

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

so it's just a different syntax? if so, lol @ u nerds spurtin about it

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Mezzanine posted:

I think it's worth it just for the "import kotlinx.android.synthetic.main.activity_foo.* " thing that handles all of the "private TextView mTextFoo;" and "mTextFoo = (TextView) findViewById(R.id.textFoo);" boilerplate with just one import line for the entire layout.

if you want to win people over, maybe don't mention the fact that you're a fan of wildcard imports

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

i honestly don't know how to respond to either of those posts. one of them implies that the poster only uses 1970s text editors without any kind of IDE functionality. the other implies the poster doesn't understand the basics of predicate logic. both of them defend wildcard imports. i'm really out of my depth in a situation where people are that ignorant and yet are insistent that their ignorance is correct and valid

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Shadow0 posted:

I'm try to make popup calendars to select a day+month+year or to select a month+year or to select a year, so I looked at the Picker class, which then directed me to the DatePickerDialog.

[...]

If I click part of the calendar that does popup, I can at least get it to show me some kind of year view. Maybe I should just go ahead and make my own version with a GridLayout.

are those the only date-picking classes in the whole android api? DatePickerDialog and DatePicker are from API level 1. i don't know much at all about this area of the API but there have definitely been some date/time pickers added over the years. for example, the clock-face time picker used in the AOSP Clock app was added (i think) sometime in the android 4.x-6.x range

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Does that mean it is possible to provide what OP is asking for simply through layout/style?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

code:
private val vm: QuestsViewModel by lazy {
    ViewModelProviders.of(this).get(QuestsViewModel::class.java)
  }
I don't know Kotlin syntax so this is probably a really babby-level question, but what's going on with this bit that you have in both classes? Based on two minutes of googlin' it looks like a variable assignment that is (effectively) deferred until the first time it's used in the code but then... the variable "vm" isn't actually used anywhere in the code?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

i was hoping i'd be able to pick it apart just by skimming, but i haven't been doing any android programming for months so i don't remember any tips and tricks when it comes to the process lifecycle. you can tell i'm really good at android programming because i didn't notice a pretty obvious "oh this must be related to stuff they stripped out of the post" bit of code :v:

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

brand engager posted:

Been working on a bug at work where a ContentProvider is dying or not being started up or something. The app is split into multiple processes so it's probably some awful concurrency bullshit. I think we also have parts of the code that just get the database itself and then interact with it which might be a nono. Anyone got some dos+don'ts for working with these that arent in the official ContentProvider guide?

What do you mean by "multiple processes"? A lot of commonly-used stuff in the standard Android API uses multithreading. The UI of your app (if it has one) is on a separate thread, AsyncTask calls use a background thread, etc. Is that what you're talking about?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Volguus posted:

On the other hand, let's look at what help can we get when we're stuck:

https://stackoverflow.com/questions/tagged/kotlin - 23,106 questions
https://stackoverflow.com/questions/tagged/java - 1,550,652 questions

are you trolling or are you really this dumb

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Volguus posted:

While I'm sure that you are a very popular and persuasive developer, you are underestimating the power of the google behemoth:

https://trends.google.com/trends/explore?date=today%205-y&q=kotlin

What happened in May 2017? Google I/O happened where they announced that Kotlin is the new language of choice for Android development. Your efforts before that, while commendable, only account for about 12% worldwide.


It goes all the way up to 11.


Lutha Mahtin posted:

are you trolling or are you really this dumb

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

SQLite has auto increment row keys but I believe these are generated per table. It sounds like OP might be having an issue where they are spawning notifications and need something more unique than "oh this came from row 35" when the user taps on the notification to launch the app?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Some classes in the Android standard library (e.g. CursorAdapter) always require inclusion of the standard SQLite "_id" row, but I don't know if that would ever matter in the case of tables also having an indexed UUID column.

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

one potential pitfall i can think of, for generating UUIDs on client devices locally, is that proper random number generation is an area that a lot of hardware and software makers tend to screw up. it sounds like it wouldn't be the most critical failure in your case, compared to e.g. implementing cryptography, but with the sheer number of cut-rate android devices out there, it might be something worth keeping an eye out for

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

netcat posted:

Does anyone know how to get the boot animation to display in landscape mode rather than portrait (for an AOSP build, Android 9)?

Our device is always in landscape mode -except- for the boot animation for some reason. It displays in portrait and when it is done the screen rotates to landscape. The image is made for landscape so it looks terrible.

can you just... rotate the image?

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Anne Bonny posted:

edit: Apparently my initial release was compatible with 0 devices. I've just submitted a new version which should show up soon.

welcome to android development, chief

Adbot
ADBOT LOVES YOU

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Is this honestly the first time that all of you geniuses are hearing about Android app stores other than Google Play? I don't know if I'd trust Android dev advice from anyone who isn't aware of that, holy crap :psyduck:

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