I'd like to start a specific launcher (set by the user), which is working fine with the code below. However, the launcher isn't moving to the user's "default" screen (e.g. the leftmost screen), but rather to the one where the user last left off. Is there a way to tell the launcher to move to the user's default screen upon opening? I've tried Intent.FLAG_ACTIVITY_NEW_TASK and Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED.
Intent home = new Intent("android.intent.action.MAIN");
home.addCategory("android.intent.category.HOME");
home.setClassName(launcherPackage, launcherActivity);
startActivity(home);
I solved this by sending the above-mentioned Intent twice (once to actually show the homescreen, and the second time to move the homescreen back to the default desktop).
Related
I have an application which works like Facebook Messenger. I can tray it and there is a small icon in the side of the screen which suppose to open the application.
I'm looking for a way to open my application without refreshing the whole Intent. I need a way to show the application as it was before the user trayed it.
User enters the application.
Starting a service of the tray icon.
App minimized (click the home button). tray apperas in the top left side of the screen.
Access another app and click the tray icon.
The tray icon should bring my application back to the main screen.
Currently, it bring the application back, but refresing my intent and all the values and texts I typed in my EditTexts are no longer there. It happens because I create a new intent:
Intent it = new Intent(this,MainActivity.class)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(it);
so how I can resume my app without overwriting the current intent?
I was trying to start activity from a service without showing it to the user, keep it work in background, I was searching a lot about that, and I found two ways to do that
by starting the activity then start the home main screen like this :
// this is for lunch the app
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.example.some");
// this is for going back
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// lets do it !
startActivity(LaunchIntent);
startActivity(startMain);
by putting a going back function in the activity itself, like this :
context.getActivity().moveTaskToBack(true);
BUT, in these two ways I have problems
in the first one, if the user was on another app, this operation will close his app and get him to home , more than that, some times the my activity not started but just be in the back without working i.e. if there was a song it isn't played
in second one, when the my activity started a black screen will appear for a second before it back to the home or previous user app
So , simply , this is what I want :
I want a behaviour equal to : the user open my app then he press back button, but without show that the app started unless he see the background apps
how to do that ?
For that, you can use an android Service.
See docs - http://developer.android.com/guide/components/services.html
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 app that spends a lot of time generating bitmaps for use as wallpaper. When the user has selected a bitmap and applied it, I would like to go to the main launcher screen so it can be seen "for real".
I could just exit the app when the selection is made, but I would like to maintain state at least for a short time so that if the user wants to go right back in to change cropping or select a different bitmap, things are as they were before.
Andy ideas? Is there an Intent I could use to get back to the main launcher screen? Maybe simulate the "Home" button being pressed?
Thanks!
An intent to go to Home:
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
startActivity(homeIntent);
I am developing an application and its Home Screen Widget.
Now from my widget when i press on a button it would open up my application from where it was left.
Means if i press home button during my application running then my application will go in background mode.
Now i want that it should resume my opened application.
Whenever i press a button from my Widget. How Can i Do it??
Please help
Thanks a bunch in advance!
I've never made a widget before, but this is how I've made a notification launch back into my original activity when you pull down the bar and click it.
Intent originalActivity = new Intent(getApplicationContext(), Widget.class);
originalActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
Once again, not sure how you would do this with a widget, but to relaunch it for a notification you convert that Intent into a PendingIntent to be called later when you want to launch back into it. I would assume this is a similar fashion for how you would it on a widget.