i need to know whether transaction style is possible or not in android , for example if i launch the main activity i need to go or switch over to second activity ,i need some animation like popup , pop for left..etc , for next activity view. whether it is possible or not?
Use Intend to go another activity.
Intent intent = new Intent(SourceActivity.this, TagetActivity.class);
startActivity(intent);
Further to understand about intend:
http://www.castlerockresearch.in/dev/2010/08/understanding-intents-and-intent-filters-in-android/
For Pop up animation see this link:
http://android-codes-examples.blogspot.com/2011/04/animated-customized-popup-transparent.html
you could use Intents for switching between 2 activities.
For the animation part please look at this How to provide animation when calling another activity in Android?
This could also be useful:
anddev.org/animation_on_new_intent-t1207.html
BR,
mybecks
Related
In my Android application I have an activity where I've been using [Activity(NoHistory=true)] to keep the activity from appearing on the activity stack.
Now I'd like to make it conditional - sometimes it should be on the activity stack so the user can press Back to return to it from a subsequent screen; sometimes it shouldn't. Is there a way to "decorate" an activity conditionally or must I write some code to accomplish this?
Thanks in advance.
Are you looking for intent flags that can be set like the one below ? You could use that to start an activity and set the flag conditionally.
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
I have an application that raises from service on scheduled time. In that service, i have displayed my Activity using Intent. It works perfectly. But, when i go back, the activity is finished. But, one blank screen is remaining there? How can i avoid this blank screen. I need my application's Activity instead of blank screen. Anyone Guide me.
#Špĸ remove this line: i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
take a look at my post if you wish to open a dialog via your service: Creating global dialogs
I don't like that you finish an activity that you go back to. You have multiple of different alternatives:
Using fragments instead of activity intents.
Set flag to indicate the activity is done so it will close when you go back.
You could also try to work with the stack, look at this: https://stackoverflow.com/a/4038637/969325
Without seeing the code it is very diffcult to find out what is going wrong in your code but still I am making some effort to help you.
Add android:theme="#android:style/Theme.Translucent" to your activity tag in your manifest file and then try if it works or not.
Have you tried setting FLAG_ACTIVITY_NO_HISTORY in the intent you use to start the AlertDialog activity or launchMode="noHistory" in the manifest.
The AlertDialog activity may very well be the blank screen you're seeing as no content view is set and the only thing a user sees is an alert dialog so once the alert dialog is dismissed and the app goes back to this screen it would be blank.
Before press back button, you have to save the state of the activity and restore the activity while come front. This is easily done by onRetainNonConfigurationInstance() and getLastNonConfigurationInstance() method. Please refer this link.
in the main activity of my app i have placed a button named as setting, if i click the button it moves to a new page where i have placed two buttons.
if i click in any of those buttons i want its corresponding operations to be done in another activity,how to do this...
in the same way if i click a button in Activity A, i need a button to be completely invisible in some other Activity...
how to do this....
The best way is to pass messages through the Intent that you use to start an activity. This answer gives a detailed code sample for this.
You can send some data along with the intent, which you used to start the other activity.
For eg, in Activity A
Intent i = new Intent(this, B.class)
b.setBooleanExtra("isButtonVisible", false);
startActivity(i);
Now in Activity B, in it's onCreate() method, use
boolean isButtonVisible=getIntent().getBooleanExtra("isButtonVisible);
if(!isVisible)
button.setVisibility(View.INVISIBLE) //Or do something with that
I think you got the idea now?
I would like to create a button in my game for the user. The button will quit the application.
Please can someone tell me if there is a way to do this.
Thanks.
Edit:
I have an activity which uses another activity with a class that extends Android.app.Application using set and get methods.
Simply using the back button switches the activities until it goes to the beginning.
I go in between these classes 20 times.
Thats why I needed a back button. But I guess there isn't so I will have to do it the long way and set everything back to the first state on quit. Thanks
There is not a way to make quit button. And there is good reason for that because the Android experience is having the back button do the closing. So you just to make the back button exit back to the home page. To do that you need make sure that your current activity is the only one oh the history stack. Then you can create a button that just calls finish(). Hope the detail explanation helps.
You probably want to mange the activity stack better.
If you look at Activity and Task Design Guidelines
it might help.
Setting the flags when you start each activity is probably the key, code such as
Intent i = new Intent(this, Whatever.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(i);
will limit the number of instances of 'whatever' to one only. ( A different flag might be more appropriate for you depending on how you want your app to run, read up about them all)
Try this:
public void quit(View view) {
if(Build.VERSION.SDK_INT>=16 && Build.VERSION.SDK_INT<21){
finishAffinity();
} else if(Build.VERSION.SDK_INT>=21){
finishAndRemoveTask();
}
}
If I read your full question, you are looking for a Reset button not exactly a quit button. I had a similar issue... the next and previous takes only one step back at a time. I wanted to go back to the very beginning. The way I acheived this is to have a class to manage the pseudocursor.. basically an int that represented which resource to pick (I used a singleton). In the main activity's Menu (android.view.Menu), I added a reset/go to beginning option. This will simply reset the pseudocursor. In my activity class's onResume(), I had the code to get the resource from the singleton. So no extra coding was required there.
Instead of having this option under Menu, you can always have a button in UI which does the same thing.
I'm developing a Twitter client for Android and I would like to know which is the better way to build my app.
I want to have a listview that, when clicked, calls another listview to see details and so on but I would also like to be able to go back in my previous list.
What is the best way to do this in Android? At every click, I create a new intent associated with an activity and I do startActivity(intent) so that I can be able to go back with the Back button of Android.
Is it a good way or is there a better approach? I would like to navigate onward and backward of n-levels
The way to navigate back in Android is by launching the Activity intent waiting for a result Doc link and then when you need to go back from the new Activity simply finish it Doc link
Calling finish() in an Activity closes it and returns to the previous one. You can call in on a button click or similar.