I have a program that I have made for Android 1.6 and up and I have been doing tests to ensure that the program works fine with the new Ice Cream Sandwich (Android 4).
Everything on the app works fine except that when a certain task has been performed by the user it is supposed to automatically launch the android browser. However for some reason it seems to load it up in the background and keeps my app shown which is not what I want it to do.
On every other version of android when I execute the code to launch the browser the browser comes to the top of the screen therefore causing my app to be in the background which is how I wanted it to work.
Below is the code that I have to launch the browser
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse(companyURL));
startActivity(intent);
The companyURL is a variable that I am using to parse the url to the browser.
Thanks for any help you can provide.
UPDATE
I have just discovered that if the browser is not currently running (i.e. not been loaded previously) when my app starts the browser it brings it to the front. However, once the browser has been previously loaded, when my app loads it up again, it loads it in the background.
Please try this it is working on ICS for me.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(companyURL));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Typically you don't need the CATEGORY_BROWSABLE category. Try the following instead:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(companyURL));
startActivity(intent);
In fact, the documentation seems to suggest CATEGORY_BROWSABLE is intended to be used in the opposite direction (browser to your app):
Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions.
http://developer.android.com/reference/android/content/Intent.html#CATEGORY_BROWSABLE
Try adding FLAG_ACTIVITY_BROUGHT_TO_FRONT flag to the intent.
I'm using following code and its working fine with me even when browser is already running in the background.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(intent);
Related
In fact, I want to be noticed when the program is downloaded without the user having to install their own apps (Install without show permissions activity).
Now I use the following code, and I want to change this code to answer my question.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
The following image is displayed after downloading the app from my server and i dont want to show
I'm trying to start default android wallpaper chooser. I'm using:
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(intent);
This code works but it opens app chooser. I want to open "Wallpapers" directly. My minSdkVersion is set to 16.
By "default" you seem to mean the wallpaper app that came with Android OS, rather than other wallpaper apps that the device may have. You can force Android to launch a particular activity by setting the component in the intent.
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
intent.setComponent(...);
startActivity(intent);
However, this is a risky thing to do. If you run this code on a device that doesn't have the wallpaper app that you've specified, then you will get an ActivityNotFoundException.
Do you really need to launch one particular wallpaper app? A central feature of Android is that you say what you want to do, and it finds the app to do it. I don't know what your goal is, but another function that might be helpful is PackageManager.resolveActivity. You can use it to discover, in code, what app would be launched for a particular intent.
http://developer.android.com/reference/android/content/pm/PackageManager.html
Hope this helps.
OK, i've tried everything (including several hours of reading and trying a lot of stuff on stackoverflow)
I'm trying to launch the default sms app from the android launcher, and using this code:
Intent smsIntent = new Intent(Intent.ACTION_MAIN);
smsIntent.addCategory(Intent.CATEGORY_DEFAULT);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(smsIntent);
break;
It works great on all phones BUT my NEXUS 5 .
Guess it has something to do with KITKAT, but not sure how to fix it..
Important - Im not trying to send the text or get it from the user (as i've seen people do here), just getting the user to the main screen of the sms app (hangouts in my case).
Thanks. :)
Intent intent = new Intent();
ComponentName cm =new ComponentName("com.google.android.talk","com.google.android.talk.SigningInActivity");
intent.setComponent(cm);
this adapter nexus, I get the ComponentName by ADB log.
I'm trying to open a link in the browser from service. The problem is that if screen is off then link does not open. Sometimes the browser opens but without any data.
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://somelink.com"));
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
If the screen is on then this code works very well. Why does not it work then screen is off?
Maybe this helps, but I don't know if it's good enought for services: https://stackoverflow.com/a/2201999/2151532
I'm trying to write a launcher-like application (I'm not planning to release it, it's just for me to use) but I don't seem to find any way to launch the Market.
All of the answers I've found actually perform a search on the Market (using a uri "market://") or even worse they run the Market on a specific app page, while I'm trying to show the main page of the Market, i.e. the page shown when you run it from the launcher.
I tried using just "market://" as a Uri, without query strings, but it doesn't work; I also tried to get exactly the same "signature" of the "start activity command" that appears in the LogCat when I run the Market from the Launcher (by manually editing component, flags and categories), but it still doesn't work.
Is there any way to get it to show the main page?
Thanks in anticipation.
Intent intent = new Intent();
intent.setClassName("com.android.vending", "com.android.vending.AssetBrowserActivity");
startActivity(intent);