|
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:
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 FAT32 SHAMER fucked around with this message at 06:37 on Feb 26, 2016 |
# ¿ Feb 26, 2016 06:30 |
|
|
# ¿ Apr 29, 2024 00:05 |
|
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 |
# ¿ Feb 26, 2016 07:07 |
|
Tunga posted:Remember that a LinearLayout defaults to horizontal unless you specifically set the orientation property. 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:
FAT32 SHAMER fucked around with this message at 18:21 on Feb 26, 2016 |
# ¿ Feb 26, 2016 16:49 |
|
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?
|
# ¿ Mar 2, 2016 19:54 |
|
speng31b posted:Tough break, but you won't forget about the gitignore next time. 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
|
# ¿ Mar 3, 2016 01:15 |
|
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!
|
# ¿ Mar 29, 2016 01:10 |
|
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. Okay, brilliant! So for instance, in this snippet of code: XML code:
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?
|
# ¿ Apr 1, 2016 03:03 |
|
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 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 FAT32 SHAMER fucked around with this message at 04:21 on Apr 1, 2016 |
# ¿ Apr 1, 2016 03:30 |
|
Volmarias posted:First step may be to change that. Yeah, I began to realize that using a HashMap as the insert argument is really dumb. I have it working now and I think that it's working, I just have to write a test class to go back and view the entries to make sure it's actually creating a db locally since i'm using the VM.
|
# ¿ Apr 1, 2016 06:21 |
|
I'm back and with more questions! So I have successfully set up a database that lets me insert poo poo with no issues and everything is amazing. Now, I'd like to be able to display this information to the user, but I'm not sure how exactly to do it. This is what I've been using: SQLiteOpenHelper class Java code:
Java code:
XML code:
I also assume that the rest of the reason for the crash is because it doesn't want to write the data to the TextView, and if that's the case, how the heck to I display it to the user? Or is it because I'm returning Null in the getJournalEntries() method? Thanks for any help or input
|
# ¿ Apr 10, 2016 03:38 |
|
baka kaba posted:What does the stack trace in your log say? It should tell you exactly where it's crashing and why (the type of exception and the error message it carries), and then further down it will probably give you the exception that caused that, and maybe there's another one that caused that... Oh wow so that's what all of that is . Here's what it output for me: code:
Welp that makes life easy, the crashes were from having two textviews in one scroll view edit: I guess I have some SQLite syntax errors floating around and a few other easy fixes, so I guess that just leaves the question of what's the best way to getting the contents of your database into a textview or similar so the user can see it FAT32 SHAMER fucked around with this message at 04:37 on Apr 10, 2016 |
# ¿ Apr 10, 2016 04:34 |
|
baka kaba posted:Yep! You should look at the docs for ScrollView, but it's basically meant as a wrapper around another view, so that if that view gets too big to fit on the screen (or the space you've allowed for it), the ScrollView will let you swipe it around. So if you want to have two TextViews, stick them in a Layout of some kind, and wrap the Layout in the ScrollView This is brilliant! Thanks so much for showing me this I edited their code for it to work with mine, but for some reason for every entry it also puts the button under it, like this: edited code! Adapter: Java code:
Java code:
XML code:
Thanks for all your help
|
# ¿ Apr 11, 2016 02:29 |
|
baka kaba posted:You need two layouts - one is for the activity, and that contains the ListView, which is like a special frame that makes a list. You put that wherever you want it on the screen. You also need a layout for your items in the list This did the trick, thank you!! And much to everyone's relief, that finishes our senior project app, so I probably won't be bothering you guys much now
|
# ¿ Apr 12, 2016 03:22 |
|
StashAugustine posted:I took a community college class on Android but the textbook was pretty garbage, and I like to have reference books for that kind of thing. Does anyone have a good recommendation for a reference for Android programming? I wouldn't really call it a reference book but I got Big Nerd Ranch's Android Programming book and it took me from knowing jack poo poo about Android to writing a decent app and laying foundations for more complicated things/indepth complicated things in the course of three weeks. Probably quicker if I had devoted more than a few minutes a day to it.
|
# ¿ Apr 14, 2016 20:21 |
|
I'm trying to import a project into AndroidStudio.app and it keeps telling me that my gradle location is wrong. Where the gently caress is it supposed to be in OSX?
|
# ¿ May 19, 2016 00:14 |
|
Turns out you have to click on the folder inside the /androidstudio.app/gradle folder
|
# ¿ May 19, 2016 18:24 |
|
Does anyone have any experience with UiAutomator? Any tips or best practices? I keep getting this weird NullExceptionPointer error when I try to have it click on android system dialog buttons so I'm not sure what's up with that
|
# ¿ Apr 19, 2017 17:48 |
|
Mezzanine posted:Pretty sure Android system dialog buttons have different "android.R.id"'s depending on the OS version, model, etc, so you may want to have it search by text or something? I managed to get it working, but the issue is I'm doing this on apk's that companies won't release the source code to us and it's extremely tedious to hook UiObject2 methods onto objects so I was hoping I'm just retarded and doing it wrong, seems like I'm not based on the results though
|
# ¿ May 2, 2017 03:19 |
|
This is probably based on your browsing habits so thanks for revealing your French maid fetish
|
# ¿ May 3, 2017 03:43 |
|
What is Kotlin going to improve with Android development? I've only recently heard of it
|
# ¿ May 17, 2017 21:03 |
|
I was really hoping that they would announce that Android would be written in open source swift from here on out so it'd be easier to port my apps to Android but noooooooo
|
# ¿ May 17, 2017 21:15 |
|
The way it's written kind of reminds me of the way Swift is written at least, just more java-like instead of ObjC/C like
|
# ¿ May 17, 2017 21:29 |
|
Has anyone tried using Kotlin to write UiAutomator tests? I'm working on that right now and if I can get some Kotlin practince in doing that it would be good practice
|
# ¿ May 17, 2017 21:35 |
|
Taffer posted:Can you explain why? I use both Kotlin and Swift daily and I vastly prefer Kotlin. Swift is better than Java obviously, but It's far behind Kotlin IMO. What makes you prefer Kotlin over Swift?
|
# ¿ May 17, 2017 21:39 |
|
If it's running using the JVM doesn't that mean it's going to have all the same issues as Java, specifically its performance compared to languages like Swift/ObjC? I'm down for easier to write Java but if it does essentially the same thing at the end of the day, I'm not sure there is much to celebrate here other than google pushing yet another shiny new thing that doesn't really change much
|
# ¿ May 17, 2017 23:30 |
|
Hell, even Go would be a huge performance improvement for android, though I understand the attachment to existing libraries. Pretty much any performance upgrade will require a language switch and a port of all the languages. Edit: after looking at some benchmarks I guess Go wouldn't be as good of a performance upgrade? Idk I heard it was fantastic compared to Java for serverside stuff
|
# ¿ May 17, 2017 23:46 |
|
I guess that's a fair point that I really didn't consider
|
# ¿ May 18, 2017 00:42 |
|
I only recently started following it after being assigned three android app dev projects at work since I'm the only one with mobile dev experience (in iOS)
|
# ¿ May 18, 2017 00:53 |
|
I think theres a bit of disappointment that they're pushing this instead of pushing something new that fixes all the issues developers face every day. It's easier to post zingers about how this is smoke and mirrors to distract us for a while than it is to look at kotlin and be like "hmm maybe i'll use this one day when Im doing something that isnt critical"
|
# ¿ May 18, 2017 19:11 |
|
Ok guys I've been trying to figure this one out all day. I have a package name that I am trying to launch but I have neither the source code nor the main activity name to be able to launch it without simulating the click on screen using UiAutomator. Anyone have any ideas on how I would go about doing this? I saw someone on Stack Overflow say something about PackageManager but I couldnt parse what it was trying to say due to being in Hinglish.
|
# ¿ May 30, 2017 22:53 |
|
Volmarias posted:adb logcat ActivityManager:V *:F Nice, thanks! I found this way of launching the package however I'm not sure why he's able to call the getPackageManager() and startActivity methods. I'm assuming it comes from a Context that is written somewhere else but I haven't written test code for a package I dont have the source code for before Java code:
|
# ¿ May 31, 2017 15:06 |
|
baka kaba posted:This is in an instrumentation test? Can you use InstrumentationRegistry.getTargetContext() for it? This worked, at least for the other apps on this device! There is an app that will only launch when you hold three physical buttons for three seconds and even though I have the package name it simply won't launch, and UiAutomator can grab the XML for me to simulate click events once the app is launched. I'm starting to wonder if the app was written weird for it to do this For the record this is a automobile head unit/nav unit that I'm working on automating testing for so that's why this has been such a bitch compared to abnormal phone/tablet
|
# ¿ Jun 1, 2017 23:16 |
|
baka kaba posted:Does it not launch at all, or does it start and immediately quit? They might have some weird Intent handler code that nopes out if you didn't launch it with the correct data It doesnt start at all and I get a "cannot call an intent from a null something something" error so I'm guessing the Intent is not exported Volmarias posted:You can always launch an activity via an explicit intent, as long as you know what the activity name is, and as long as the activity is marked as exported. You press the Volume button + brightness button + home button for three seconds, I have no idea what they're overriding but it's pretty neato bandito (except for the part where i have to mark it as a semi-automated test instead of a fully automated test )
|
# ¿ Jun 2, 2017 01:27 |
|
Volmarias posted:Redact the package name but post the error log here. What process gives that, the process you're trying to call, or the system_service? code:
Java code:
|
# ¿ Jun 2, 2017 14:38 |
|
baka kaba posted:Well you're getting it from this Nah it just means instead of trying to launch it via an activity i will have to use a CAN database to simulate the signal that pressing the button does. The same thing happens when I try to launch the HVAC settings via activity instead of hitting the hard button, which tells me that it only wants a CAN/MOST signal instead of pure android implementation
|
# ¿ Jun 2, 2017 16:43 |
|
Volmarias posted:
I tried every package name that the logcat spat out and none of them worked Are package names supposed to have slashes like com.bench.tuner/AMTuner or do I have to do some kind of string handling to handle the / character
|
# ¿ Jun 3, 2017 02:59 |
|
Volmarias posted:The slash delineates the package name from the activity. Rather than repeating the entire package name, it strips the part that's already been provided. So, com.foo.bar with an activity at com.foo.bar.main.Butts would be represented as com.foo.bar/.main.Butts (I think it's .main and not main, but confirm this yourself) I'll have to check it out on monday and see if I can figure anything else out. I wont be able to get any source code from the client and with how modified the OS appears to be I'm guessing that i'm in some uncharted waters and will have to do it the hard way
|
# ¿ Jun 3, 2017 05:06 |
|
Ok here's the adb logcat ActivityManager:V *:F log dump when I launch the hidden app using button presses.code:
code:
|
# ¿ Jun 5, 2017 16:19 |
|
baka kaba posted:I saw you're using getContext() - did you try getTargetContext() instead? I'm not sure exactly how it will work for what you're doing, but the target context is for the thing under instrumentation, instead of the thing running the tests Hmm, that seems to be giving me the same java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Intent android.content.Intent.addFlags(int)' on a null object reference. Google hasnt exactly been very helpful in looking for clues on this one either so i'm not 100% sure.
|
# ¿ Jun 5, 2017 19:00 |
|
|
# ¿ Apr 29, 2024 00:05 |
|
Volmarias posted:Do this to start the diagnostics app: That being said, the only fix I had to add was intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) after the clear task flag method call to get this to work . I wish I had caught on to your hints sooner, I didnt realize that you could specify intent class names using the .setClassName() method and google is wicked sparse on the details for doing anything with AndroidJUnit/UiAutomator for some reason (i'm assuming because most places have smarter people than me to figure it out ) Thanks for this!
|
# ¿ Jun 6, 2017 19:19 |