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
speng31b
May 8, 2010

sort of moot, the legacy dev could've used the same keystore (don't do this. no really don't do this) for all his/her apps and not feel comfortable handing it over to someone new, in which case they might have no choice.

speng31b fucked around with this message at 19:06 on Feb 21, 2016

Adbot
ADBOT LOVES YOU

Tunga
May 7, 2004

Grimey Drawer

kitten smoothie posted:

Which you'd need anyway if you wanted to push a final update to the old one that just says "new one is over here," so that should be moot.
Yes but that could be done by the original dev without handing over the keystore and password.

speng31b posted:

sort of moot, the legacy dev could've used the same keystore (don't do this. no really don't do this) for all his/her apps and not feel comfortable handing it over to someone new, in which case they might have no choice.
Yeah, basically this. We had an issue at my old company where we had an app that was made by an agency and then we brought it in-house and we had to make a new store listing for it because "oops we sign all our apps with the same key so we can't give it to you". Which I'm pretty sure was in breach of the contract but nobody within my company actually cared about the app (the project got canned about a month after I finished rewriting it) so I was told to just make a new listing.

speng31b
May 8, 2010

I've noticed something pretty weird happening with one of my personal apps, curious if anyone has any ideas.

Yesterday it got a huge spike in daily active users, daily new users, etc, like more than 1000% increase. At first I thought it got featured somewhere or something, then I looked at the analytics and notice it's all coming from two device models, both running API 19, both oldish tablets:

samsung SHW-M500W
LGE LG-V480

Both register as unrooted (as far as Crashlytics root detection goes anyhow), and there are many concurrent installations going for each device model - so not just one device per model, lots of these devices. From the button click analytics, it looks like there's some fairly large number of these devices just roboting through my app since yesterday, clicking random buttons, doing random stuff, then uninstalling and reinstalling and doing it again. I don't get a Google Analytics referrer links for any of this stuff, so I'm guessing the APK was manually installed on some robot farm of these aging tablets which as I type this is happily smashing my app with random input.

Not sure what the point of this is. Think maybe some automated testing service picked up my APK as a test case?

speng31b fucked around with this message at 18:14 on Feb 22, 2016

kitten smoothie
Dec 29, 2001

Someone running a fuzzer on a device farm comprised of cheap old crap they could get off eBay?

NoDamage
Dec 2, 2000
Can someone confirm whether the NDK documentation is indeed completely out of date when it comes to building C++ code with the latest Android Studio? From my preliminary research it looks like what they describe (editing the Android.mk and Application.mk files to specify build settings) has been entirely replaced with options in build.gradle.

Edit: It looks like NDK support in Android Studio is horrendously incomplete. Argh.

Edit 2: Finally got everything to work (Java calling into C++ code that uses the standard library and links against a pre-built static library). What should have taken a few minutes with the proper documentation ended up taking an entire day to sort out. Had to upgrade to the experimental version of gradle to get support for static library dependencies, and then a lot of trial-and-error guessing at the new gradle syntax to get the compiler flags and dependencies specified correctly. I would do a writeup of how to get everything running but it's probably pointless cause it will likely change again soon.

NoDamage fucked around with this message at 08:52 on Feb 24, 2016

Thom ZombieForm
Oct 29, 2010

I will eat you alive
I will eat you alive
I will eat you alive
Using/learning android studio/programming for a class project. The android emulator is running very slow, and I have onboard graphics card (thinkpad). Will I be happier by purchasing some cheap android phone to plug in for testing, and if so what is recommended (I have an iphone til contract expires : )

Tunga
May 7, 2004

Grimey Drawer

Thom ZombieForm posted:

Using/learning android studio/programming for a class project. The android emulator is running very slow, and I have onboard graphics card (thinkpad). Will I be happier by purchasing some cheap android phone to plug in for testing, and if so what is recommended (I have an iphone til contract expires : )
Make sure you have the latest versions of everything in the SDK and that you're using the x86_64 images. The new emulator is fast and good.

Edit: You also need to be running the latest beta release of Android Studio 2.0 but it's perfectly usage and stable at this point, we all use it at work on production code.

http://tools.android.com/tech-docs/emulator

Tunga fucked around with this message at 18:53 on Feb 24, 2016

Chas McGill
Oct 29, 2010

loves Fat Philippe
I want to make an app where you can arrange shapes that snap onto one another at fixed points (like lego). It could be in 2d or isometric rather than 3d. Is it possible to do stuff like that through canvas or should I be looking at a game engine? I'm picturing the user dragging stuff into a drawing area from a toolbox.

speng31b
May 8, 2010

Tunga posted:

Make sure you have the latest versions of everything in the SDK and that you're using the x86_64 images. The new emulator is fast and good.

Edit: You also need to be running the latest beta release of Android Studio 2.0 but it's perfectly usage and stable at this point, we all use it at work on production code.

http://tools.android.com/tech-docs/emulator

Yeah even without HAXM the new emulator is pretty okay, but keep in mind for someone using something without hardware virtualization support it's not going to be as fast and good as it might be for you. Emulators are neat, but my recommendation would be to test and develop on real devices as often as possible, for lots of reasons.

Chas McGill posted:

I want to make an app where you can arrange shapes that snap onto one another at fixed points (like lego). It could be in 2d or isometric rather than 3d. Is it possible to do stuff like that through canvas or should I be looking at a game engine? I'm picturing the user dragging stuff into a drawing area from a toolbox.

I made this app: https://play.google.com/store/apps/details?id=com.ludomade.blueprint which is currently the most popular wireframing tool on the Play Store as far as I can tell. Its core mechanic is shape-snapping on a zoomable/scrollable grid. I used Canvas for the whole thing and it runs perfectly well as far back as Android 4.1 with basically zero crashes, and even runs pretty well on crappy tablets that most people had resigned to collecting dust in a corner. Using Canvas let me develop it quickly and iterate on it rapidly in response to user feedback - I considered a game engine when I conceived the idea, but I'm glad I didn't do that. In retrospect I couldn't have built it nearly as well or quickly or made it mesh as well with existing UI conventions if I'd used an engine.

e:

Earlier when I said basically zero crashes, I actually mean literally zero crashes as far back as Crashlytics goes with almost 50K installs - I'm pretty proud of that one, might as well drop it in there.

speng31b fucked around with this message at 02:27 on Feb 25, 2016

Chas McGill
Oct 29, 2010

loves Fat Philippe

speng31b posted:

I made this app: https://play.google.com/store/apps/details?id=com.ludomade.blueprint which is currently the most popular wireframing tool on the Play Store as far as I can tell. Its core mechanic is shape-snapping on a zoomable/scrollable grid. I used Canvas for the whole thing and it runs perfectly well as far back as Android 4.1 with basically zero crashes, and even runs pretty well on crappy tablets that most people had resigned to collecting dust in a corner. Using Canvas let me develop it quickly and iterate on it rapidly in response to user feedback - I considered a game engine when I conceived the idea, but I'm glad I didn't do that. In retrospect I couldn't have built it nearly as well or quickly or made it mesh as well with existing UI conventions if I'd used an engine.
I actually have that app installed and I've used it for interaction design homework! Small world. I was thinking of something more basic: like unresizable tetris style rectangles. It's good to know that something like this is possible without an engine.

Looking at the canvas documentation now. I have so much to learn. I'm planning my final degree project and I'm teetering between actually coding an app or making a lovely 'high fidelity' prototype in something like AppInventor...

Chas McGill fucked around with this message at 22:33 on Feb 24, 2016

FAT32 SHAMER
Aug 16, 2012



Hey guys, I've been going through the Big Nerd Ranch book and it's given me a massive amount of insight and I actually feel like I have some idea of what I'm doing now, which is great! I'm not sure if this is the right thread to ask, but I'm trying to create an Activity that asks the user to chose how they are feeling based on an emoji. After some research, I found that GridLayout seems to be best suited for what I want to do. Unfortunately, when I try to add a title at the top, it buggers my centre column up. On top of that, the padding for the images is kind of weird and I can't figure out why.

XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context="tusentakk.blueharmony.FeelingActivity"
    android:background="@color/backgroundBlue">


    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnCount="3"
        >

        <ImageView
            android:id="@+id/feeling_angry"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_angry"
            android:layout_column="0"
            android:layout_row="1"

            />

        <ImageView
            android:id="@+id/feeling_excited"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_excited"
            android:layout_column="1"
            android:layout_row="1"

            />

        <ImageView
            android:id="@+id/feeling_furious"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_furious"
            android:layout_column="2"
            android:layout_row="1"

            />

        <ImageView
            android:id="@+id/feeling_happy"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_happy"
            android:layout_column="0"
            android:layout_row="2"

            />

        <ImageView
            android:id="@+id/feeling_numb"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_numb"
            android:layout_column="1"
            android:layout_row="2"

            />

        <ImageView
            android:id="@+id/feeling_overjoyed"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_overjoyed"
            android:layout_column="2"
            android:layout_row="2"

            />

        <ImageView
            android:id="@+id/feeling_overwhelmed"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_overwhelmed"
            android:layout_column="0"
            android:layout_row="3"

            />

        <ImageView
            android:id="@+id/feeling_sad"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_sad"
            android:layout_column="1"
            android:layout_row="3"

            />

        <ImageView
            android:id="@+id/feeling_worried"
            android:layout_width="116dp"
            android:layout_height="116dp"
            android:src="@drawable/feeling_worried"
            android:layout_column="2"
            android:layout_row="3"

            />

    </GridLayout>


</RelativeLayout>

results in this


My thinking was that if I nested the GridLayout inside of the Relative Layout, I would be able to put a TextView nested before the GridLayout began, then I would be able to not bugger the column sizes up. Does anyone have any guidance on this? I've been loving with it for the last hour and a half

edit: I read that there is a way to have content span across multiple columns, but I can't figure that one out either :shobon:

FAT32 SHAMER fucked around with this message at 06:37 on Feb 26, 2016

brap
Aug 23, 2004

Grimey Drawer
I would make the GridLayout the child of a vertical LinearLayout and put a Toolbar above it to show the title. But I'm not an expert.

FAT32 SHAMER
Aug 16, 2012



fleshweasel posted:

I would make the GridLayout the child of a vertical LinearLayout and put a Toolbar above it to show the title. But I'm not an expert.

Doing this pushed the images to the top, which is good, but when I add the toolbar it makes the images disappear, which also happened when I tried using a RelativeLayout as the parent followed by a TextView before the GridLayout child.

Also, semi-related question: for the images to be clickable, I assume you just add android:clickable="true" and android:onClick="emotion", yeah? Or is it more similar to how you make a TextView a link to a new activity?

FAT32 SHAMER fucked around with this message at 07:09 on Feb 26, 2016

Tunga
May 7, 2004

Grimey Drawer
Remember that a LinearLayout defaults to horizontal unless you specifically set the orientation property.

And for RelativeLayout you have to use layout_below or similar to set up the relative layout of the children, were you doing that?

Basically can you post the code that isn't working?

FAT32 SHAMER
Aug 16, 2012



Tunga posted:

Remember that a LinearLayout defaults to horizontal unless you specifically set the orientation property.

And for RelativeLayout you have to use layout_below or similar to set up the relative layout of the children, were you doing that?

Basically can you post the code that isn't working?

Nice! adding layout_below did the trick! Thanks 😊

edit: Here is what I have so far, for our senior project we wanted to build an app that allowed mental health patients to keep track of their moods among other things. I didn't pick any of the colours nor the logo, but I think it's turning out rather nicely. One weird thing to note is that the FeelingsActivity in the VM looks different from how the Android Studio Preview puts it

https://www.youtube.com/watch?v=ZOxiJQ4-tOc



versus



I suspect it may be because I defined the TextView textSize="30p" but I'm not sure

XML code:
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="tusentakk.blueharmony.FeelingActivity"
    android:background="@color/backgroundBlue"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <TextView
        android:id="@+id/title_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title_string"
        android:textSize="30dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"/>

    <GridLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:rowCount="3"
        android:layout_below="@id/title_text"
        android:paddingRight="8dp"
        >


        <ImageView
            android:id="@+id/feeling_angry"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_angry"
            android:layout_column="0"
            android:layout_row="0"
            android:clickable="true"
            android:onClick="angry"
            />

        <ImageView
            android:id="@+id/feeling_excited"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_excited"
            android:layout_column="1"
            android:layout_row="0"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_furious"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_furious"
            android:layout_column="2"
            android:layout_row="0"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_happy"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_happy"
            android:layout_column="0"
            android:layout_row="1"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_numb"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_numb"
            android:layout_column="1"
            android:layout_row="1"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_overjoyed"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_overjoyed"
            android:layout_column="2"
            android:layout_row="1"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_overwhelmed"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_overwhelmed"
            android:layout_column="0"
            android:layout_row="2"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_sad"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_sad"
            android:layout_column="1"
            android:layout_row="2"
            android:clickable="true"
            />

        <ImageView
            android:id="@+id/feeling_worried"
            android:layout_width="125dp"
            android:layout_height="125dp"
            android:src="@drawable/feeling_worried"
            android:layout_column="2"
            android:layout_row="2"
            android:clickable="true"
            />


    </GridLayout>
</RelativeLayout>
Considering three weeks ago I was lost and overwhelmed, I'm super stoked about my progress so far

FAT32 SHAMER fucked around with this message at 18:21 on Feb 26, 2016

Tunga
May 7, 2004

Grimey Drawer
Text sizes should be set in SP, not DP. And remember that different devices will display things a little differently due to screen ratios density buckets, etc. That's the nature of Android and your layouts should be adaptable.

an skeleton
Apr 23, 2012

scowls @ u
Hey guys, I'm a newb android developer; I'm more of a web dev, but still a student so we have to develop an Android app for our senior design project at school.

One of the parts of the project is documenting the architectural style. Here's where I need help. Our group is in agreement about Android being comparable to an MVC architecture. Where we disagree is where the line is between model and controller; I feel like the controller is an activity/fragment but that any "fat" business or algorithmic logic, as well as any data schema definition/ORM stuff should be considered the Model. One of my colleagues is pretty adamant that business logic and such should go in the controller/activity.

There doesn't seem to be a cut and dry consensus, does anyone have any opinions? We're all terrible at android so we're kind of guessing at this point.

speng31b
May 8, 2010

Tunga posted:

Text sizes should be set in SP, not DP. And remember that different devices will display things a little differently due to screen ratios density buckets, etc. That's the nature of Android and your layouts should be adaptable.

Counterpoint, if you're going to be too lazy to test that your layouts don't break when your text resizes based on compatibility settings you should set them in DP and suppress the warning. Small text is better than text that you can't read at all because it's clipping outside the view.

an skeleton posted:

Hey guys, I'm a newb android developer; I'm more of a web dev, but still a student so we have to develop an Android app for our senior design project at school.

One of the parts of the project is documenting the architectural style. Here's where I need help. Our group is in agreement about Android being comparable to an MVC architecture. Where we disagree is where the line is between model and controller; I feel like the controller is an activity/fragment but that any "fat" business or algorithmic logic, as well as any data schema definition/ORM stuff should be considered the Model. One of my colleagues is pretty adamant that business logic and such should go in the controller/activity.

There doesn't seem to be a cut and dry consensus, does anyone have any opinions? We're all terrible at android so we're kind of guessing at this point.

Modern architecture has people treating Activities/Fragments more as views, keeping them lightweight, and putting presenter logic elsewhere. You don't put business logic in the model regardless. This has been linked a few times in the thread, just read it over and get informed, then see what you think: https://codelabs.developers.google.com/codelabs/android-testing/index.html?index=..%2F..%2Findex (I know it says testing, but just read it for the architecture stuff)

Tunga
May 7, 2004

Grimey Drawer

speng31b posted:

Counterpoint, if you're going to be too lazy to test that your layouts don't break when your text resizes based on compatibility settings you should set them in DP and suppress the warning. Small text is better than text that you can't read at all because it's clipping outside the view.
Well, true, but better to learn to not write lovely inflexible layouts in the first place.

speng31b posted:

Modern architecture has people treating Activities/Fragments more as views, keeping them lightweight, and putting presenter logic elsewhere. You don't put business logic in the model regardless. This has been linked a few times in the thread, just read it over and get informed, then see what you think: https://codelabs.developers.google.com/codelabs/android-testing/index.html?index=..%2F..%2Findex (I know it says testing, but just read it for the architecture stuff)
Yeah, this. We use something pretty close to MVP though all of these patterns are a bit weird on Android and don't map exactly. MVVM can also work.

speng31b
May 8, 2010

Tunga posted:

Well, true, but better to learn to not write lovely inflexible layouts in the first place.

Yeah for your general body copy this is true, it just helps to keep in mind that the purpose of SP is accessibility - so if it doesn't make your app more accessible to use SP, don't. This is often the case in real applications when designers use text essentially as glorified static imagery, in layouts where the design effect relies on text being a certain size relative to other text or the layout itself. There are plenty of apps live right now with all kinds of text that will happily scale with SP, but it does pretty much the opposite of making the app more usable. I'm glad the lint warning exists, because it forces developers to think about when SP makes sense, but lots of people have taken that to mean "slavishly use SP for all text even when it doesn't make sense." Don't do that.

FAT32 SHAMER
Aug 16, 2012



Okay here's a question:

I've been developing our senior project Android App on OS X and the only other person that has been pulling/submitting/messing with it is also on OS X, however today one of our partners pulled then opened Android Studio and the committed the changes, and it hosed everything up to the point that I had to roll back to a previous commit

is there a way to prevent this from happening so that the Windows users can work on the app with us or is this a totally different issue?

MrBlandAverage
Jul 2, 2003

GNNAAAARRRR

Tusen Takk posted:

Okay here's a question:

I've been developing our senior project Android App on OS X and the only other person that has been pulling/submitting/messing with it is also on OS X, however today one of our partners pulled then opened Android Studio and the committed the changes, and it hosed everything up to the point that I had to roll back to a previous commit

is there a way to prevent this from happening so that the Windows users can work on the app with us or is this a totally different issue?

https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems

For what it's worth, my project also ignores the .idea directory and all .iml files.

Tunga
May 7, 2004

Grimey Drawer
If everyone is using Android Studio it really shouldn't matter what OS you're using unless you did some spectacularly bad with your .gitignore.

speng31b
May 8, 2010

Tough break, but you won't forget about the gitignore next time.

https://github.com/github/gitignore bookmark it

FAT32 SHAMER
Aug 16, 2012



speng31b posted:

Tough break, but you won't forget about the gitignore next time.

https://github.com/github/gitignore bookmark it

Nice! Thanks :)


Tunga posted:

If everyone is using Android Studio it really shouldn't matter what OS you're using unless you did some spectacularly bad with your .gitignore.

I went over the commits and it looks like it changed the SDK and gradle file locations because on mac its in a different part than windows or something

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
You shouldn't be committing files that have paths outside of your repository. Remove them and add them to your gitignore file.

TheReverend
Jun 21, 2005

i have to do android project. Coming from IOS this makes me sad.

Is it any easier to do on windows v.s OSX?

I don't care which OS I use. I just want the path of least resistance.

Also, I started android studio, set my target to API 19 but it set my compile sdk to 21 and my build tools to 23 is that right?


I'm in for some...fun?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

OS X is fine for Android work. Maybe better, because it has a better terminal and shell, which you'll periodically have to flex.

speng31b
May 8, 2010

There's no maybe about it, OSX is better, if only for not having to deal with ADB drivers for all the devices you want to test on.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

I think every Android presentation I've ever watched was run off a Macbook

TheReverend
Jun 21, 2005

Re drivers:

It says my Nexus 6p has API1 on the device list on osx...

speng31b
May 8, 2010

Anyone done any testing on Android N and found any major pitfalls? Been in a crunch-time project and haven't had a chance to check it out as much as I'd like.

b0lt
Apr 29, 2005

speng31b posted:

Anyone done any testing on Android N and found any major pitfalls? Been in a crunch-time project and haven't had a chance to check it out as much as I'd like.

If you're using the NDK, linking against or dlopening private libraries will stop working as soon as your application has a target SDK level of N or greater.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat
Hi guys, quick question about Dagger 2. I think I read that any class with an @Inject annotated constructor is one that Dagger implicitly understands how to create. So does that mean I literally don't need to expose it anywhere? Not in a module with @Provides, nor as a method in a component? Sorry if this is a bit of a dumb question, I'm kind of diving head first into dependency injectors.

speng31b
May 8, 2010

Yeah @Inject annotating a class's constructor should make it globally available to DI. Also, genuinely not trying to be snarky or whatever, but one of the cool things about Dagger/Dagger2 is that it will give you compile time errors explaining very well what you can and can't do, so the quickest way to find answers to questions about how Dagger works is usually to try to compile it and see if it works, and if not, what the compile error was. Also take a look at the generated code to see how scoping and stuff like that works; it's pretty straightforward so even the generated code tends to be pretty clear and easy to follow.

FAT32 SHAMER
Aug 16, 2012



Hey guys, more newbie questions! We are implementing a page in our app and we would like it so if you click on a TextView for, say, the Suicide Prevention hotline, it will ask you if you wish to dial the phone number. However, i can't seem to figure out how to do this.

I also can't figure out how to make a TextView a clickable link that opens chrome and takes the user to a certain website. I'm not sure if it can take you to a different app or if it can just pop up a little "web view"? thing that you doesn't remove you from the app itself.

Thanks for the help!

Fergus Mac Roich
Nov 5, 2008

Soiled Meat

Tusen Takk posted:

Hey guys, more newbie questions! We are implementing a page in our app and we would like it so if you click on a TextView for, say, the Suicide Prevention hotline, it will ask you if you wish to dial the phone number. However, i can't seem to figure out how to do this.

I also can't figure out how to make a TextView a clickable link that opens chrome and takes the user to a certain website. I'm not sure if it can take you to a different app or if it can just pop up a little "web view"? thing that you doesn't remove you from the app itself.

Thanks for the help!

The parent class View has the methods setClickable() and setOnClickListener(). All you need to do is make sure that clickable is set to true and then set a listener that does whatever you darned well please. You can do this in XML with the android:clickable attribute and the android:onClick attribute. I do not recommend using the latter as the method you use is required to be in the activity, which IMO gets a little unwieldy, so my preference is to get a reference to the TextView in code and set a listener for it. Listeners are easy to write, if you haven't written one yet.

Since a listener can contain any code you want, all of the things you mentioned are possible.

Lucky for you, Android provides a facility to make clicking on text with a phone number and dialing it REALLY simple. Check out this XML attribute. I don't think you even need an OnClickListener for that view. As far as opening up a page, it should be relatively straightforward. Your OnClickListener can do something that swaps the appropriate fragment or view with a fragment or naked WebView(this documentation also tells you how to open the browser).

speng31b posted:

Yeah @Inject annotating a class's constructor should make it globally available to DI. Also, genuinely not trying to be snarky or whatever, but one of the cool things about Dagger/Dagger2 is that it will give you compile time errors explaining very well what you can and can't do, so the quickest way to find answers to questions about how Dagger works is usually to try to compile it and see if it works, and if not, what the compile error was. Also take a look at the generated code to see how scoping and stuff like that works; it's pretty straightforward so even the generated code tends to be pretty clear and easy to follow.

Thanks! And I'll be sure to do experiment and take care of that compile time guarantee in the future.

speng31b
May 8, 2010

Tusen Takk posted:

Hey guys, more newbie questions! We are implementing a page in our app and we would like it so if you click on a TextView for, say, the Suicide Prevention hotline, it will ask you if you wish to dial the phone number. However, i can't seem to figure out how to do this.

I also can't figure out how to make a TextView a clickable link that opens chrome and takes the user to a certain website. I'm not sure if it can take you to a different app or if it can just pop up a little "web view"? thing that you doesn't remove you from the app itself.

Thanks for the help!

Webviews are loving godawful for about a thousand reasons, use an intent to open the browser if you need to view an external page, or better yet, Chrome custom tabs (https://developer.chrome.com/multidevice/android/customtabs) - the new hotness because they're smooth and nice and good and not at all loving unbelievably terrible like webviews.

Don't use webviews unless you've run out of all other options. One of the few legitimate uses of webviews is for oauth when services don't provide a decent client library for it. MAYBE for a minimally styled page without scripts, like a Terms & Conditions/Legal, that you need to update without the overhead of a release. Otherwise, just don't use a stupid loving webview.

speng31b fucked around with this message at 05:16 on Mar 29, 2016

FAT32 SHAMER
Aug 16, 2012



Fergus Mac Roich posted:

The parent class View has the methods setClickable() and setOnClickListener(). All you need to do is make sure that clickable is set to true and then set a listener that does whatever you darned well please. You can do this in XML with the android:clickable attribute and the android:onClick attribute. I do not recommend using the latter as the method you use is required to be in the activity, which IMO gets a little unwieldy, so my preference is to get a reference to the TextView in code and set a listener for it. Listeners are easy to write, if you haven't written one yet.

Since a listener can contain any code you want, all of the things you mentioned are possible.

Lucky for you, Android provides a facility to make clicking on text with a phone number and dialing it REALLY simple. Check out this XML attribute. I don't think you even need an OnClickListener for that view. As far as opening up a page, it should be relatively straightforward. Your OnClickListener can do something that swaps the appropriate fragment or view with a fragment or naked WebView(this documentation also tells you how to open the browser).

Okay, brilliant! So for instance, in this snippet of code:

XML code:
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="20dp"
        android:text="Suicide Prevention Hotline: 1(800)273-8255"
        android:autoLink="phone"
        />
and that's that?

With the web links, can it be embedded like this or do i have to actually put the web link in a separate TextView with the actual URL spelled out?

Adbot
ADBOT LOVES YOU

FAT32 SHAMER
Aug 16, 2012



Oh and since this is a different subject, I'll double post:

I have a database that already exists that I have imported into Android Studio, and I would like to be able to insert values into it and keep it super simple just for demonstration purposes because the database that my partner decided to use for the website version of the app doesn't allow external connections and i didn't figure this out until it was already built out and it would be too annoying to backtrack and use something like firebase or whatever

SO I'm using the SQLiteOpenHelper and I'm struggling trying to figure out how to simply insert. I found this article but it seems to be for read-only database and doesn't have a way to actually write to the database. I tried using it anyways but I've been trying to figure this out for a few days and I'm getting to my wits end since all the online demos for the SQLiteOpenHelper class are for single-table databases


Here is the structure of my database with all the tables and columns:


Extrapolating what I've read, I think I would need to create an insert method for each table, so for instance insertJournal would insert the user's journal entry into the database, and insertFeeling would insert whether the user selected a certain feeling to accompany how they were feeling when they wrote that journal entry. I just can't figure out how to properly write an insert method that doesn't make the app crash and then call it from a different class in order to write whatever the user entered to it.

I'm positive that there has to be a simpler way to do it than what I have so far, so any guidance would be amazing :3:

Sorry i've been blowing this thread up lately, I have to do a dry run on the working product in two weeks and this has been my limiting factor.



edit: jesus christ i just watched a youtube video about it and inserting is way, way less complicated than i've been making it

I don't think I need help anymore :shobon:

FAT32 SHAMER fucked around with this message at 04:21 on Apr 1, 2016

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