i am iOS app developer. Now when i created an app on iOS i want to do the same on android. With java i was familiar just now need some time to remember.
i was looking at some tutorial how to do one or other things. But what i can't find is the basics how everything works. How classes is interacting with each other.
For example i want to create registration window with few buttons and alerts.
I want registration window to be called just once when app is installed and just that.
Should i create new java class and few layouts, one for View with buttons and other for Alerts ?
Or should i create other class for alerts if i need them in other flow of my app ?
And how i should call that window with registration from my main class, which is
extends Activity
Also if there are some developers who came this road from objective-c (iOS) to java (android). It would be nice for some share experience how they did that.
Thank you for any help :)
Very few of the concepts in iOS and Android are similar. On Android you have Activites, Intendts the Manifest. When you design your layout it should be resolution independent. You have a search, back and a menu button and variable hardware. All of this has no equivalent in iOS.
That said, I think you just have to read the basic concepts and the getting started guide no matter if you come from iOS or never have done mobile development before.
EDIT
To answer your concrete question. Take a look at the lifecycle of an Activity and Preferences. With this, you could do some action on the first start of your main Activity and store some flag in the preferences when it's done. On the next start you just test that preference and skip the logic.
You can create one activity (.java file) and one layout(.xml file with buttons and input boxes) , alerts could be toast notifications:
http://developer.android.com/guide/topics/ui/notifiers/toasts.html
All you require for this is a activity and a layout xml for that activity, this activity will be your main ie the entry point to your application, in that activity oncreate method you can check if it is registered or not by setting a flag or something which will direct to the next activity if its registered.
GOOD LUCK...
Just like your nibs in iPhone you create xml layouts in Android. And for view controllers here you make activity. One important thing is AndroidManifest.xml file, it contains all information of your app (like plist) plus all the activity information(Intent type and launcher methods).
Related
This may be a silly question but I have the following situation: I want to setup my window layout every time the app is open, for example changing the status bar color. So I created my Application file because I heard it is better if you check something like this in the application file and not in the MainActivity.
Problem: How can I call the getWindow() method without an open activity.
Thanks for helping.
A bit tricky, but you can use Window manager in background-service to display your views without opening an Activity.
Also, for API Level 26+ (Oreo or above) you have to start your service as foreground service
I have a simple kids app which teaches things such as colors, numbers, etc... which I am currently developing. It uses what I would consider "standard android java programming (Single Xml/java class)." I also have a simple game with a Dinosaur that jumps over letters using libgdx.
My question is, I would like to have the game as part of the "overall" app. I would like to know if it is even possible to add a libgdx game to an android native application. I tried adding the appropriate files to my app, but this caused a compile error, could someone point me to a place where I could find help on this issue, or perhaps let me know if what I am wanting to do is even possible? Thanks.
---To clairify, my main app has a menu which takes you to activities. I would like the libgdx game to be one of the activities.
---Edit to response---I compile using Gradle and have more errors than I can count. I've since removed the libgdx game from the app so I am not sure of specific errors, but iirc there were over 100, many of which were R issues, which I could have figured out, but I couldn't find anything on either S.O. or the web saying it was even possible to add libgdx to a non-libgdx app.
You can integrate your App with your libgdx game.
AndroidLauncher.java is your libgdx Activity and you can move from one activity to another using Intent.
intent = new Intent(this, AndroidLauncher.class);
startActivity(intent);
and movement from libgdx AndroidLauncher.java, you need to call it from inside the core project classes. You need to use an interface.
https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code
If your game is sub view of your App.The AndroidApplication class (which extends activity) has a method named initializeForView(ApplicationListener, AndroidApplicationConfiguration) that will return a View you can add to your layout.
Pros.-Code is already you have,only you need to integrate.
Cons.-you need to maintain OpenGL Context Loss. Libgdx do for you.
In Libgdx your entire game is just a single Activity. You can start it as any other activity from your code.
Please follow Can I run an Activity before running libgdx? for details.
I'm a bit confused as to wether I should create a plain activity or a fragmentactivity. My app is displaying an expandableListView and a dialog. Thats it (pretty much).
I cannot find any instance that my app would be better if I used a fragmentActivtiy because first of all my app is not designed for tablets, and second I'm not adding or doing anything to my main activity during runtime to change the views.
My problem is that it seems it is a must to use fragments, because when I checked out Android dev site on dialogs, it only explains how to implement them using fragments. Are plain activities highly un-recommended or I just have to judge my app, and are all features such as dialogs available for plain activities? (And can someone please give me a link to a good source where I can learn about dialogs in a normal activity?)
http://developer.android.com/guide/topics/ui/dialogs.html
It says here that you should use a fragment but does that mean i have to go all out and make my main activity a fragment?
Here is some discussion about using Fragment or Activity for dialog: Show fragment as a dialog or as a usual activity
If you want to make your dialog as Activity, hope this tutorial helps:
How to create Dialog activity in Android?
A FragmentActivity is an Activity because it extends Activity See here. The question the mean to ask is really a question for your self, do you want your app to support API >= 11 (3.0 Honeycomb) or API >= 4?
In API 11 Android introduced the concept of Fragments to deal with creating apps particularly tablets. But to add support for all the devices still running < 11 they created the Support v4 library which is where FragmentActivity lives.
If you are not using Fragments at all then just use Activity because it's available at all API levels. (it just got added functionality in >=11). If you want to support >=4 and may use Fragments then use FragmentActivity and your covered. I noticed things in the v4 library have started to be deprecated (starting to be phased out by Google). Personally, I won't make a new app with API <14 and suggest you stay above 11.
As far as Dialogs go. You don't need to used a DialogFragment but same question above applies to API level. I typically just used Dialog to show mine even if I'm using Fragments.
Hopefully this clears some things up for you. Happy Codin'
I am developing an application using the Action Bar Compact.
Right now I'm trying to set the Activity Application Preferences.
As Java does not have multiple inheritance can not inherit both ActionBarCompact and Preference Activity.
I need a way to use the two classes at a time, so you can use the Action-bar to navigate and to use Preference Activity activity as Preferences.
PS: My apologies if the question is not clear, my English is not quite good.
This is an Android noob question.
I am trying to start an activity of another apk through my own application. Now I know I can launch any other application and invoke its main activity. In many cases I'm also able to start subactivities, for example display it's settings dialogue.
However with some applications, for example Facebook or Endomondo I would get a FC everytime I try to launch some specific activity of their application.
Now I suspect that this is a permission issue and that the Facebook or Endomondo devs just don't want other applications to get access to their activities. But do I have to find out which activities I can use and which ones I can't use by trial and error every single time?
Plus: Is there any way around this dilemma? Maybe on a rooted device?
Cheers for any pointers.
As you already said you can only use activities of other apps which are designed to be used by others applications. Normally the developer of the other app define a set of intents and actions their app will be able to understand and process.
Using any other app's activity is by default not possible, this is by design of Android as every app runs in it own sandboxed process (there are some exceptions where apps can share a process).
So to use another app's activities you must know the intents it listen on. Normally this can be found in the applications website or documentation or on OpenIntents a dictionary for intents.