Using overridePendingTransition() to animate the first Activity - android

I'm trying to use overridePendingTransition() to animate the very first Activity - the one that gets created when the user launches the app. Is this possible?
Where should I call overridePendingTransition()?
Tried right after super.onCreate() and right after super.onStart() , but it didn't work.
I would prefer to manage this at runtime, rather than setting the #anim in a custom style. Couldn't find anything. Is it possible?

from experience all I will say is it will not WORK to make it work you need to use a workaround, which is create a transparent launcher activity, carrying the app name and everything without a View (that is do not set content view) and make it transparent as I said with this code this.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); and immediately call your "in real life splash screen or launcher activity", and put this.overridePendingTransition(R.anim.grow_from_middle,R.anim.shrink_to_middle); in its onresume() (anywhere you prefer, I prefer this) and voila you have it..

Related

Is there something like an "app layout" in android?

I'm explaining what I refer to with "app layout".
I'd like to call another app from android but at the same time staying in my own app, this can be visualized with having a border that would be from my own app and inside that border the app I'd like to call would be executing. New app would be then some sort of activity from original app.
The reason for doing this is that we'd like to keep always our app permanent meanwhile we can take advantage of apps that do perfectly some things that our app should do.
I think that if a web layout is possible so should be this, maybe it's not implemented or it would be pretty complicated to do, but it could be done.
Hope someone can guide me with this.
Out of the box - no, that's not possible.
You can call other app activities with startActivityForResult() and have your app re-invoked with result available in onActivityResult() callback when the activity finishes. The called activity will have its own UI and won't display in your app's frame.
If the called activity is your own and you can modify the code, you can make it dialog style with transparent margins/padding that show parts of your calling activity underneath.

Android dialog called as intent is not showing the background screen. It is showing black backgroud

I am calling a dialog as Intent from the main application screen.
Now when the dialog opens, it is showing black backgroud.
I want to show the main application in the backgroud even thought the dialog is opened as intent.
opening a new intent means that your application will call atleast onPause, more likely even onStop.
if you want to do what you're doing - even if thats not androids way things should be done - then you have to overwrite the handling of your "background" activitys onStop so that it's not removeing the activity from view.
however, i've never done that and i'm not even sure if its possible.
it dosn't seem to be a good idea anyway.
why dont you look around how other apps - few of them for sure haveing the same problem - work around it and still got a nice looking UI?
oh btw, you know that you don't have to open a dialog as a new itent for showing it - do you?
It sounds like you need to apply the Dialog theme to the activity that implements your dialog:
<activity android:theme="#android:style/Theme.Dialog">
See http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme

how to change/reset custom theme from Java code in android

I have a change theme option in setting screen of my application and providing some custom themes to choose from .
first of all i believe you can't set theme to entire app from your java code at once (please guide if there is any way to do so ) , thats why i am calling setTheme(my_theme) before super.onCreate() in every activity of app .
Now when user change activity, this will reflect only at the time of relaunching any activity (becouse setTheme() is in OnCreate() ).
So issue is how to let SetTheme() works in OnResume() or anywhere else in code , because i want to reflect these changes on previous screens in Activity Stack also .
note that setTheme() works before setContentVIew() only ......
Yeah, as the docs say, you need to set the theme before any views are instantiated, so it looks like you will need to restart your entire activity.
There's probably a better way, but one way to ensure your activities completely restart in onResume():
finish();
startActivity(getIntent());
This will recycle the existing intent. However, I would first look around to see if there is a simpler way to ensure activities restart- might be a simple manifest property. Let us know what you find.

Transparent, floating Android Activity doesn't allow updates to content behind it

I have tried and tried to get a transparent, floating Activity to show up (as an overlay), but allow whatever is behind it to still show AND update. Right now it seems that if the Activity behind mine is closed or a new one opens (could be either in this case), the new underneath Activity does not shine through my Activity to the user.
I have tried every combination of Flags I can come up with, and at this point I'm assuming Flags are not the answer. Can anyone help me find the proper code to do such a thing?
Before anyone asks, I have a valid use case for this type of Activity; no, I don't plan to annoy the user with it.
As far as I know, this is not possible. It should be possible to create an activity using the theme Theme.Dialog or Theme.Translucent (see http://developer.android.com/guide/topics/ui/themes.html) to have whatever activity is beneath it still show at least partially. The problem is, is that the Activity below will be Paused (it's onPause will have fired, but it's onStop will not have) and I don't believe it is possible in any way to have it run any code.
I have not investigated in making a transparent Activity but I don't think it's possible in an Activity way. This seems to be logical since even if you have a transparent Activity it's still relying on the View inside it - the View makes the transparent part, not the Activity. This means you're probably gonna end up with a transparent View instead.
If you have a "front" Activity with a transparent View and then a "back" Activity, the "back" Activity would not be visible to the user - and that's because you're in another Activity.
So, the correct way is to use a transparent View.
It is possible to update the activity below by implementing a Broadcast receiver on it, and sending Broadcasts from whenever you want.

How can I keep current screen (contentView) when l Iaunch a new Activity

I have an NoContentViewActivity which has no Content View (i.e. I did not call setContentView() in the onCreate of my Activity).
My question is how can I keep the content view of the launching activity on the screen? Right now, I am getting a blank screen whenever I launch NoContentViewActivity? I want the content view of the launching activity (the activity which start the NoContentViewActivity) to show on the screen.
Thank you for any help.
Excuse me, people, but my guess is that hap497 wants exactly the thing he wants. There is a bunch of situations where invisible activity would fit while Service will not.
Imaging you want to show a set of dialogs, each next of them is shown after the previous one based on the user choices. And imaging you want to have this (exactly the same) functionality to be available when pressing different buttons on different (lots of them) activities.
To write the same dialog processing logic would be an overkill whether the transparent activity will deal nicely...
Anyway, as stated above, all you need to do is to specify:
android:theme="#android:style/Theme.Translucent"
or
android:theme="#android:style/Theme.Translucent.NoTitleBar"
(if you do not want a titlebar either)
It sounds like you'd be better off using a Service than an Activity. Activities are for code that is to be viewed; Services are for code that runs without a UI, which is what it sounds like you want.
An Activity with no Views assigned is an empty black screen, so it will still obscure the calling Activity. You could make your Activity transparent by assigning it a transparent theme:
android:theme="#style/Theme.Translucent"
Keep in mind though, that your invisible Activity will have focus, so the user won't be able to interact with the Activity underneath.
Why do you want to create a fully transparent Activity? As Daniel suggests, a Service might be a better solution to your problem if you genuinely don't want any user interaction.

Categories

Resources