This Android app developing business is accelerating the brown-to-grey-color conversion of my hair.
Can someone tell me how I'm supposed to get aFunction() to run when the app starts, seeing as I'm not supposed to make a while(true) inside onCreate()?
I've read the tutorial on Android Developer, several other tutorials, multiple questions on here, but none have answered this, seemingly, simple question. Or, at least I haven't been able to find it - without a doubt because I'm asking the wrong question to the great oracle of Amphitheatre Parkway.
The app is my first homemade non-tutorial app, and I'm attempting to make a speedometer based on GPS (obviously). Basic stuff I guess. It needs to update ever so often which I'm using Thread.sleep() for. Setting up LocationManager, getting location, calculating distance and speed is working. Printing the speed is working. Everything, except making it run, is working (he claims in his naivety).
Android development (and in fact most GUI development) is very different than the console development you may have done in the past. The main difference is that GUIs are event-driven. You typically create what are called "callback methods" which respond to events. This allows the system to do other things rather than waiting for a while(true) loop in your app. I am unfamiliar with using GPS in an Android app. You will need to research what callbacks are necessary to deal with GPS notifications. I suggest starting with Making Your App Location Aware and Location and Maps.
Related
I'm knee deep in this commercial game and currently working on the in-game chat. How I code the chat system depends on rather or not threading will work.
My question(s)....
Does anyone know for sure calling a thread on android or ios will result in a separate process and not hold up the app until complete?
This worries me because I came across another python user who was developing some form of app and they stated that their thread did not run as an individual and their app froze up until the thread completed. (which sucks because python is a cross-platform language)
What I wanna do is have a thread periodically fetch chat data from the server without causing the whole app to pause while doing so. This will allow for a more professional looking chat system and better user experience.
However, if for some reason python threads will not act as expected, I'll have to use a different logic for the chat system.
I'm sure some of you will probably be like, "just test it" but that's just it....I don't wanna (want to, lol) write all that code just to re-write it all over again if for some reason threading doesn't act right on a phone.
I'm not asking for code here....God knows I can code the hell out of an alien battle cruiser from planet Zars equipped with warp 7.5 engines.
If no one can give me a for sure answer then.... (sigh)...... I'll have to just write the code and cross my fingers in hopes of accurate threading behavior on phones for python programmers or be faced with the devastating task of re-writing a large chunk of code..... on the client and server side!
=====================Update as of July 14 2017==============================
I went ahead and wrote the code anyway. Turns out the Kivy API set has some back-end issue with creating Rectangle draw instructions in a python thread. This issue doesn't seem to be relevant when creating widgets from within a thread.
I did find a work around for the draw instruction issues and had things the way I pictured it all but in the end... I saw more cons than pros in the way I was planning my chat system and decided to re-write it anyway.
The new chat system is easier to work with and I don't have to implement code and fonts for multiple languages. (phew!)
So....looking at my original question now....
Yes,
Python threads will run on their own cpu cycle on an Android phone but what you're trying to accomplish depends on your entire setup...back-end and front end APIs.
I'm surprised to see people assume python can't thread when the language has the modules for threading.
Hell I run threaded processes separate from the main thread all the time on PC. In fact, I have this nice email app which can generate emails and send out ads/flyers and maintain a valid email database.
The app uses threading to update the UI system so the user of the app knows what's going on in the background. It's a marketing tool I plan on using later after I release the current app I'm designing now.
I might even release my marketing tool but such a high quality app wouldn't be cheap on the market. Not when marketing cost so much money. Being able to reach your target audience at little to no cost... Sounds too good to be true.
:)
I've been programming for over 20 years, but mostly in the VB and SQL. As a side job, I host game shows at local bars and restaurants (Trivia, name that tune, etc.) and I'd like to develop an android app that I can install on mobile devices to give to customers to interact with the game.
I'm trying to make the game shows more interactive than just pen and paper (and time-consuming, manual scoring). I can get Kindle Fires for $40 each, so I thought it would be cool to create an app that will allow the user to do 3 things:
Choose an answer from a list (Multiple choice), and everyone can answer
Buzz in (blocking other users out)
type in an answer
I'd like the tablets to send the responses to a central "hub" or application that will record the answers so it can automatically do the scoring for me. If possible, I'd prefer to be able to have everything connect through an ad hoc wifi network that I would set up on site (that part I know how to do, too).
I'm not looking to have the questions appear on the phone at this point; I have an office-based application that automates a powerpoint presentation based on questions/answers and other parameters imported from a database/spreadsheet. (VBA is nice and easy for me.)
Ideally, the quiz questions would work like this:
I project the answer where everyone can see it.
After announcing the questions, the tablet apps are "activated" and
the user can then select their A, B, C or D answer (or buzz in, or
type an answer depending the type of questions/quiz).
My hub application would then receive the following information:
team/player name, answer choice, time it took to answer the question
(because I'm thinking of using a points tier that gives faster
players get more points, either based on time ).
The catch is, I don't even know where to begin from an android development standpoint, as I have no experience in that realm. In most programming cases, I know keywords to search on, but I'm totally flying blind here.
Does this seem like a feasibly application? There are systems online that I can buy, but the buzzers are expensive and the software has some significant limitations that prevent me from spending the money. I'd rather develop something myself and spend $40 per client unit and load it up with my software.
(Then, of course, license the whole kit and kaboodle and make a mint and retire in 5 years, living the good life off of my pub quiz empire...)
So, if you have any suggestions on starting points, or specific methods and processes to being fiddling with, an IDE...any help would be greatly appreciated. Once I'm up and running, I will reward you with extra points if you ever come to one of my events.
Go full kotlin !
Android works well with Kotlin and you can have a server quickly setup with : https://start.spring.io/#!language=kotlin
https://kotlinlang.org/docs/tutorials/kotlin-android.html
A good client for Android is provided here :
https://github.com/square/retrofit
You will probably have hard time to get started. Using same language for every part of the system will make things easier.
Also, Kotlin is less verbose than Java and will prevent you to make the usual mistakes found in Java world.
Also, if you create an open source project out of it, you may be eligible for IntelliJ.
Your very first stop is : http://try.kotlinlang.org/#/Examples/Hello,%20world!/Simplest%20version/Simplest%20version.kt
Get to know the language by trying it out. When you are in ease with it, start looking at Anko (https://github.com/Kotlin/anko).
To do the project in an easy way, break it down in milestones.
Simple app which shows 4 buttons (choices) and shows a message for each button. (Eg. you clicked "1")
Small server with spring boot. It should display whatever you post to it. (An "echo" server)
Improvement of the simple app to POST something to the server and display the answer in a dialog.
At that point, you application is practically done! You would have understood enough to complete it. The hardest thing would be behind.
Don't think your are smarter than the flock. Do these milestones, at least. You will be thankful to yourself.
This post may seems unrelated, but I explain how good Kotlin can be in such projects : https://www.linkedin.com/pulse/why-do-android-projects-cost-less-than-ios-christian-baune
I am a long time lurker on Stack Overflow where generally the solutions I sought already existed on here. However, I am stumped trying to find information on tackling this problem.
Basically, I am looking at making an Android app - first time making such an app - and part of the functionality is to monitor what else the phone user is doing and then maybe create a log of what the person has done. For example, spent 27% of the time when the phone screen is on using Facebook.
As for my actual Android Studio experience, all I have created so far is a simple app that takes in text from an input field and alerts it back out to you. I am studying a video series to learn how to use and develop with Android Studio.
I am enthusiastic about the challenge, so if anyone has some good resources or information to help me achieve this I would be really grateful.
Yes it is possible to track applications usage, using google API.
Here is google resource link
What may interest you the most is the part concerning UsageStats
You can use this since api 5.0. You can then for example use method getTotalTimeInForeground() to get the total time this package spent in the foreground, measured in milliseconds, which seems to correspond to your needs.
Therefore, using your Facebook example. After you get the package name (com.facebook.katana) , you could get the application (Facebook) uptime on a daily/weekly/monthly base.
Also, you could use getLastTimeUsed() and make your application logs those timestamp then do some maths.
I realize that cutting off a notification after an amount of time is odd and unexpected, but I am creating a Phonegap application for a user study group in which this functionality is necessary. I have tried several methods of achieving this through Phonegap background mode plugins but each has there own quirks and would not work reliably due to Android memory management.
What I am thinking now is that I will modify the Android side of this plugin:
https://github.com/katzer/cordova-plugin-local-notifications
To cancel a notification after three minutes since it has triggered. I have talked to the developer of this plugin and he says it's not possible on his end but I don't mind trying to fix it myself. I don't have a lot of Android experience however, and am not sure if I would be wasting my time in trying. Is there any way this would work?
Edit:
I can go into further detail about what I have tried in the past, however I have arrived at the conclusion that these pursuits are dead ends-- They are all Phonegap plugin oriented and do not address the fundamental problem of Android's memory management system killing my running Javascript components that limit notification duration. Because of this, I figured I would change the Android side of my code.
Unfortunately, I have no experience in Android and have so far found learning Android daunting and the framework complex in my early research. It would be a waste of time to research an involved topic like the Android framework if it turns out that I cannot even do what I need to do. This is why I asked if it was possible or not; it is much easier and quicker for someone to tell me 'no', and obviate the need for me to research, than it is for me to research and understand a topic to the point that I can come to the conclusion myself.
It is very easy, there is a cancel method for notifications:
cancel() : - Cancel a previously shown notification
cancelAll () : - Cancel all previously shown notifications.
Currently i am developing an Android Hybrid application. I am pretty new to Android development but picking up new things pretty much every day. This Hybrid application is build upon the Sencha Touch 2.3.1 framework. The project consists out of the following of main goals.
Functionality:
Getting the current GPS location. (Backed by 2G/3G or WiFi if needed)
Reading the current accelerometer values. (Used for a fall-detection algorithm)
Scanning QR codes. (I will probably use a library for this function)
Setting a timer and let it run in the background.
All of the above should 'run' in the Native part of the application.
General question: What would be the best way of doing this, in terms of architecture/base structure?
To get a little more specific on the answer i would like to get, here is some more information.
Currently the native part (Activity) of the application looks somewhat like this. It declares and initializes the WebView and loads the URL which refers to the host where my Sencha Touch application is hosted. So far this is the only Activity/Class i have. And also works properly.
I am using the following bridge to communicate back and forth between the hybrid and native part of the application. In the example on GitHub they stuffed all of the functionality in one Java class. (Activity)
In my case this would mean for my project, that all of the Hybrid to Native function calls, like getting the current GPS status, set a timer in the background or start the camera will reside in the main Activity. Thus getting quite big in time, i could imagine.
Sub question: Is this the way to go, or should i split up all of the core functionality in separate classes?
Scenario:
The GPS sensor takes quite some time to get a fix, so the user should not be interrupted while the GPS keeps searching for the current coordinates. (Again this can be backed by 2G/3G or WiFi if needed and available)
Sub question: Should this or any other background functionality be handled in a separate thread? Or in the same Activity where the WebView resides? Or can i just simply create a new thread within the Activity that handles the GPS and/or other functionality that require to run on the background?
As you can see i am trying to figure out the best way of structuring the application on the Native side.
For the threading part (Functionality that runs in the background, such as a timer or GPS that waits for the correct coordinates) i wanted to use IntentService, because the functionality has to keep running and also finishing their tasks, even when the application is not active/minimized. Plus the same task is bound to be handled again. (Re-using the thread?) So when i speak of threading or threads in this question, i mean using the IntentServices.
I hope i was clear enough. Thanks for reading so far.
(Pseudo)Coding answers are appreciated, but showing me the best/correct structure (Image or 'just in words' -like) would be preferred. Then again, do as you prefer.