android. One activity to rule them all :) - android

This is more of a curiosity than anything else but it would be good to get some feedback from everyone on possible problems and solutions etc.
Is it possible to use one "host" activity and use that activity to display 3-4 different activities?
I already use tab host in my app and this doesn't seem to fit my needs in regard to the menu idea, ill explain what I'm trying to do as it may help.
Im trying to find a nice clean solution to playing background music, but this could be applied to other functions as well, but essentially, after the splash screen i would like a "host" activity to load first and in that activity, load up a menu activity, when the use presses a button the menu activity, i would like the next activity to load up still inside the "host" activity.
I'm hoping this would make playing music etc as clean as possible and with as little extra coding as possible.
Is this idea possible? would it be beneficial? what would be the best way to accomplish this?
Like i said this is more of a curiousity than a "gimme code to do it", I can work that out once i know the direction to head in & if its possible, I mainly want this for b/g music at the moment but im sure this could be applied other functions.
Thanks for looking, reading giving your thoughts :)
phil

Related

Starting a function in the onCreate (without a button click)?

I know this might be a basic question, but I am a beginner and I haven't been able to find an answer.
I would like to know, if it is possible to trigger some function/action while creating an activity. eg. trigger a void without user intervention, start an animation automatically after an Activity is created etc.(at the moment I am trying to trigger an animation without a button click, but this question is general and not specific code related).
I know how to bind an action to a button click and every resource I have found is doing that, I haven't, however, been able to start an animation or a void without it and I am not sure if it is possible. (I have tried using Handler, it worked but prevented the rest of the code being executed - I might have done it wrong, though as I really am a beginner)
so my question(s): Is it possible to trigger a function/animation without user intervention(click)?
If so, where can I find some resources to read about it? (I tried reading Android documentation already)
Thank you very much and I apologize if the question is too simple, I know it might be.
Please have a look at this photo.
It clearly explains the lifecycle of Android activity.
To answer your question, yes, it is possible to trigger a function/animation without user intervention(click). You have to call the function from onStart() activity.

Android App with Fragments/Actionbar: How to run code when startup is totally finished?

I am writing an android app that uses Fragments and an ActionBar.
Is there a simple way to know when the entire app has finished starting up? Each fragment has it's own layout, and my startup code needs to touch them all. Is there an event I could use to accomplish this?
Thanks!!
onCreateView is called after the view is "all there", so its a good place for code that needs to run late in the game. You could set a flag here or send an event to notify other views that you're ready, but it is per fragment.
However, fragments are kind of based on the idea that they will be created as needed. In a normal app they come and go dynamically so there isnt ever a time when the "whole app is loaded". So, there isnt going to be a single place you can check for whether all fragments are ready unless you make your own. Before doing that you might want to consider other ways to accomplish the task at hand. Your design may not be a good one if you are having to fight against the underlying system.

Android app display on top of another

I'm trying to build an application that would run at the same time as another one, on top of it (hiding only partially the original app), that would display useful information for the user of the main app.
But it seems that 2 activities cannot run at the same time, overlap, etc...
For argument sake, lets say the app would be displaying date & time in a corner of the screen, while playing a specific game.
Anyone got any doc or sample code on how to achieve such a result ?
I'm also interested in how to know which app is currently running in order to decide in my app-on-top to be visible or invisible.
Any help appreciated :)
Thx
Looks like you are in need of Fragments: Fragments
The Android system is designed to be user friendly, and two activities at same time is not, so only one activity is on foreground at once. if you need the other to be running in background make it a Service, if you want to show some data and get back first one use a Dialog, finally if you want both you can either put them in one activity or use Fragments as #Tooroop suggsets.
Its propably too late ... but for others with the same problem:
check out how-to-draw-on-top-of-other-applications
and maybe also this if your app need to be on top on fullscreen apps

What's the best way to realize a startscreen?

Can someone tell me what's the best way to realize a startscreen in android. What I meant is when you open the app than a image appears a few seconds and in the background the app is loading?
Here is another example, which does not utilize a separate activity.

what are best practices for showing help information

I would like to put fairly extensive help information within my app - both "how to use" and explanation of what one is seeing.
The app (map oriented) has a row of buttons at the bottom, and I was considering adding a help button.
Context sensitive help is mostly not appropriate, btw.
What are common and best practices for this?
Thanks
I wouldn't suggest using a help button, once the user knows how to use your app it will be useless, and will only takes some space.
What I do (but it's maybe not the best practice) is to show a popup on the first use. Within the popup I put some basic help and a link to my website which fully explains how my app works (with some screenshots to make it user-friendly). I also put a "Help" button in the activity menu which redirects to my website again.
What I can suggest is to explore by yourself how other android apps shows the help information, and reuse or adapt the one you prefer (this is what I've done).
I have put help into a menu item as I expect new users to click the menu button anyway (my app, Zwitscher also has a button bar at the bottom).
Clicking the menu item then starts an Activity that simply shows a table view that explains the various buttons in the system and contains a link to more information online.
See https://github.com/pilhuhn/ZwitscherA/blob/master/src/de/bsd/zwitscher/HelpActivity.java and
https://github.com/pilhuhn/ZwitscherA/blob/master/res/layout/help.xml
Another option I've seen sometimes is including a help option in the preferences/configuration screen.
Usually it starts a new activity with a sequence of steps to make the user understand everything.

Categories

Resources