I am new in android development. I have two activities in first activity there is only a button by which i am calling next activity using intent and in second activity i am doing the actual work i.e. i am getting the values from web using SOAP.
So , My problem is that when i go from 1st activity to the second activity it shows me a BLACK screen until the next activity gets loaded totally since the response fron web is large.
I want to add a progress bar from my 1st activity to second gets loaded totally to avoid this black screen.
Do anyone have any ides about this.
Thanks in advance.....
You have four realistic solutions i would say in my opinion
1- Threads
2- Asyntask
3- Service
4- External lib
If you are doing lot of small downloads classic Theading is the best option maybe with a service to manage it, but not forced.
For one simple download you can use Asynctask alone. It can be enough but you must know several things about this method : AsyncTask can be "Bugged" according to the way you use it.
Service is good you can use it. A download module using service is a good idea to manage the requests.
The best solution for a quick/efficient developement is to use a library that do the work for you. But in your case you are using SOAP... If you where using Json you could make use of Volley which is very good and fast.
Maybe try to use this one which is well known
http://code.google.com/p/ksoap2-android/
with the how to http://code.google.com/p/ksoap2-android/wiki/HowToUse
For the moment when to do the operation you have several solutions
1- In background without blocking the ui, updating the ui View per View
2- Using a loading screen (bad for user experience but sometimes you don't have a choice)
In your case you would have the loading screen between the first activity and the second using a ProgressDialog maybe
Related
In my UWP-App I want to create an app internal contactbook page. I can select a contact and return the selected contact back to the page where I opened the contactbook.
In Android where I come from there is a function called "startActivityForResult" which opens an activity gets the return value when finished.
I want to create the same behaviour.
I did this with Frame.Navigate(typeof(ContactBook)) and then when the contact is selected I navigate back with Frame.Navigate(typeof(PreviousPage), selectedContact)
The method Frame.GoBack() is useless in this case because I can't pass a parameter.
How can I solve this problem?
I'm not 100% familiar with android and "startActivityForResult" but are you looking to navigate the entire frame away? There isn't any equivalent in UWP apps, nor is there even really one for WPF's showDialog(), which is probably what you're looking for.
You only have a few options and none of them are really "amazing" per-say.
You can do what you've done above, which is navigate away to the page that has all the contacts, then navigate to a new page but depending on how your app is layed out you might be losing data on the page (since it's a new instance and not a back in the stack so you can't really cache it). You also can't navigate to an instance of a page either, it's only to a new page or through the stack from back / forward. If you use GoBack though and cache the page (using the "required" mode for caching) then you could do some dirty lookup of a stored value in a static class (I know, ugly and not MVVM) or setting a local settings value and reading that in the OnNavigatedTo() method for the page before.
If you don't NEED to use frame movement, you can use a flyout or a custom flyout user control to build a popup of sorts that will display the XAML for the page instead of a page frame. This will have a few difficulties with resizing (so more so for W10 than W10M) and such but you'll be able to not transition out of the frame itself. Then you can see the value of the selected and then on the submit event, you can just work with the page since it's already open.
If need be you could build a custom usercontrol for the flyout and put some custom dependency properties that can be bound for MVVM, it really all depends on what and how you're doing it.
So short answer, there is no fast way of achieveing what you're looking for and that does seem like an issue with the API. I would make the suggestion on the API's uservoice (https://wpdev.uservoice.com/forums/110705-universal-windows-platform) and try to get it upvoted!
There isn't any equivalent in UWP apps, nor is there even really one for WPF's showDialog(), which is probably what you're looking for.
#Daniel, no, there is a equivalent in UWP apps. Please refer to Launch an app for results, you can follow the tutorial in that doc to achieve this.
To do this, you will need to create two apps. One is the app which will launch the result app (let say "main app"), the other app here should be the contact-book app. The contact-book app will behavior like a modal window, and the main app will wait for the result of the contact-book app.
But in an UWP app, you can use ContactStore class to access the database that contains contacts.
So, you will need to reconsider if that is necessary to create a contact app by yourself.
Edit:
I may misunderstand your question, you just want your page to behavior like contact-book, not want to create a contact-book by yourself. But anyway, it's the same, you can create another app to hold your page which you want to launch from your main app.
I am using android studio with an emulator. When I change the code, I need to test it. The thing is, sometimes I have to perform a dozen click, fetch data from internet, etc, until I get to the screen I want to.
Is there a way for me to "save" the activity state, and quickly jump back to that activity after having changed the code? That would save me hours of dev.
I'm opened to any other tips that would speed up my testing process
Thanks!
You can Make the Activity you are trying to test as your launching Activity and feed it with seed data that you are trying to fetch from the internet. It will save you a lot of man hours. I would suggest you to go for a TDD approach rather using Robotium where you can test all the functional code of yours.
I'm developing an AR app that's going to contain an activity with a Unity3d model. Creating such an activity is something I can do now but I've come across another problem.
To show a unity model in an activity, the latter has to extend the UnityPlayerActivity class. What if I want to load the 3D model as soon as my launch activity starts but show it in one of the following ones? My goal would be to have the user wait for the model to be loaded as the app starts (e.g. when I show them a splash screen) so that when they change activity to the one that contains the AR view the waiting time is minimal.
I know this is possible in iOS and would like to replicate that behaviour in android as well. Any ideas?
As I suspected - there aren't any answers to my question.
I'll answer my question myself with a workaround, then, and wait for someone else to come up or for the creators of Unity to provide us with the same functionality under Android as under iOS.
To achieve the desired effect, I decided to only have 1 activity and multiple fragments. The activity extends UnityPlayerActivity meaning that when it loads, that takes the time Unity needs to load. Then, when navigating throughout the app, I only swap fragments containing entire screens and make use of the UnityPlayer.pause() and UnityPlayer.resume() methods, as well as the setVisibility method to make it go away.
Hope that helps if anyone has any similar issues.
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.
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