I am trying to launch the Google's SMS Messenger app from my activity without any animation. I tried adding the flag FLAG_ACTIVITY_NO_ANIMATION while launching it. But still it launches with that default animation (my activity is pushed to the background and the new activity launches from bottom of the screen). I am not sure if I am doing something wrong here or it is a problem with the Messenger app itself, that it is not honoring that flag.
Code below:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("sms:222222222"));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
Have also tried adding the below line after the activity was started, but doesn't help.
overridePendingTransition(0,0);
Related
I got an app which can receive an event (which is basically a message from a service in the background), and when it does, I am invoking this code:
Intent dialogIntent = new Intent(this, MainActivity.class);
dialogIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialogIntent);
This code is supposed to return the app to the front so the user can handle the event.
This code works only if the app I'm working on was also the last app the user has been in. The code doesn't work in these scenarios:
1) The user has paused the app, opened another app and then paused it too so the 2nd app is the last in the background - in which case the last app will always open, even though I'm starting my MainActivity. For example, if I've moved my app to the background, opened Android's settings and then an event is received, the Android's settings screen will open instead of my app.
2) The user is inside another app. In which case, the app won't be brought to the front at all.
How can I made the specific app to be resumed from the background no matter what?
Use launcher category as below:
Intent resumeIntent = new Intent(context, MainActivity.class);
resumeIntent.setAction(Intent.ACTION_MAIN);
resumeIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(resumeIntent);
Also add android:launchMode="singleTop" in the manifest of your activity.
You can add android:launchMode="singleTop" in the manifest for the Activity.
I have a broadcast receiver launching a transparent activity while my application is either not launched at all or is in the background. This transparent activity behaves like a pop-up-box that appears on top of the android OS (thus transparent).
If my application is not launched at the moment (exists neither in foreground nor background), when the broadcast receiver triggers the start intent action everything behaves as it should and my transparent activity appears on top of the android OS.
I have another scenario where my application is paused - is in the background. From this state, if my broadcast receiver is triggering the action to start the transparent activity it does so in a way that it moves my last activity on the screen and my 'transparent activity' on top of it thus not being transparent anymore, I can see through it the contents of the activity behind it (from my application). This behavior is not desired and I wan't to change it in a way that when the pop up activity is started, the activity that was before be invisible. How can I do this, how can I hide all other activities from my app in the stack and have only the last one visible !?
This is how I send the intent:
Intent intent = new Intent(getApplicationContext(), PopTestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
use this
Intent intent = new Intent(getApplicationContext(), PopTestActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
I am launching skype with the below code from a button click.
Uri skypeUri = Uri.parse(uri.toString());
Intent myIntent = new Intent("android.intent.action.CALL_PRIVILEGED", skypeUri);
myIntent.setComponent(new ComponentName("com.skype.raider", "com.skype.raider.Main"));
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
appContext.startActivity(myIntent);
It gets launched as a seperate activity and my app goes in background. When call is done, and i click on my app from background running apps, it starts from first screen however the call was placed from third screen. Any idea where I am wrong in implementation.
I want my app to go to background as soon as call button is clicked. When i am done with skype call and starts it again from background running apps it should not start from first screen. It should start from that 3rd screen only where i left it.
Thanks
I have an application where after a certain amount of time I want all activities in the app's stack to be removed and replaced by a login activity screen. I've got a Runnable timer that issues this set of statements:
Intent intent = new Intent( ctx, mainActivity.class );
intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP );
ctx.startActivity( intent );
This works fine when my app is in the foreground, however, when my app is in the background and I'm using another app (say, the Web Browser), the timer fires as it should and pops up the login activity screen to the foreground.
What I want is for the login activity to be activated and moved to the front of the stack, and have all other activities in the stack removed, but not have the app and activity popped to the foreground over any currently running app.
Is there any way to do this with a different method or flag? Thanks.
You could probably finish() the login activity in the onCreate event, conditional on an intent extra. Hopefully it would then be closed before it is displayed...
Im having trouble getting this to work, hereĀ“s a quick overview of the idea.
First, I cant change the logic behind this, it was a specific requirement from the customer, I realize that with any tool such as AnyCut it could be bypassed but that doesnt matter really.
My customer offers a suite of apps, the idea is that all applications bellonging to the suite would be launched from a "Dashboard app", so that I only show the Dashboard app in the main launcher and not all app icons.
Lets take two Apps to get the idea solved. The Dashboard App (A) and the Recieving App (B).
I want to establish an intent filter (I think) on app B so that whenever I go into app A, and click the app B icon the app will be either launched or started from where it let of (brought to front).
Is this even possible? If so, how can I do it? I managed to get it to launch by specifically launching one activity in the app using:
Intent i = new Intent();
i.setClassName("PACKAGE_NAME","SPECIFIC_CLASS");
startActivity(i);
But that isnt the behaviour that I want, as it always starts app B in the same spot.
Thanx in advance,
Stefano
Edit: Added some new information. I was taking a look at the DDMS.
If I launch the application from scratch through the main Android launcher the intent is exactly the same as when I leave the home button pressed and then only bring the app to front, what ever activity im in. So I was trying to reproduce, unsucsesfully until now, this intent.
INFO/ActivityManager(1292): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.package/.uiPackage.Activity}
This is how AnyCut does it
Intent { act=android.intent.action.VIEW flg=0x10000000 cmp=com.example.package/.uiPackage.Activity bnds=[125,242][235,360]}
Any idea how I could go about creating that exact same intent? I cant even find that flag in the Intent API.
Figured it out, this is how I did it.
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setAction("android.intent.action.VIEW");
i.setComponent(ComponentName.unflattenFromString("com.example.package/com.example.package.activityName"));
startActivity(i);
I'm not quite sure I'm following the expected results you want to see, but the following would launch the app from the dashboard and remove the dashboard from the activity stack leaving the selected app running:
Intent i = new Intent();
i.setClassName("PACKAGE_NAME","SPECIFIC_CLASS");
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
I believe this should start the app as if you were starting any other app.
Please add more information on your logic if this is not what you are looking for.
I think that when you switch activities android's default action is to sort of pause or hold the activity in its state the user left it in last. I know there is a way to make it so that the state is not saved when switching activities but I cant remember it off the top of my head.