Document directory
- How does Android call the system's default browser for access?
Today, you need to add a shortcut to the desktop so that you can link to a specific webpage when you click it. I found this article online.
Http://www.moandroid.com /? P = 1699
It was inspired to implement this function.
/*
* Add shortcuts to the desktop
* @ Param icon shortcut icon
* @ Param name shortcut name
* @ Param Uri the intent URI of the shortcut
*/
Public VoidAddshortcut (parcelable icon, string name, Uri URI ){
Intent intentaddshortcut =NewIntent (Action_add_shortcut);
// Add a name
Intentaddshortcut. putextra (intent.Extra_shortcut_name, Name );
// Add an icon
Intentaddshortcut. putextra (intent.Extra_shortcut_icon_resource, Icon );
// Set the launcher's Uri data
Intent intentlauncher =NewIntent ();
Intentlauncher. setdata (URI );
// Add a shortcut startup Method
Intentaddshortcut. putextra (intent.Extra_shortcut_intent, Intentlauncher );
Sendbroadcast (intentaddshortcut );
}
Of course, you also need to add a permission
<Uses-Permission Android: Name ="Com. Android. launcher. Permission. install_shortcut"/>
How to obtain the first parcelable icon is as follows.
Parcelable icon = intent. Specify cuticonresource.Fromcontext(This, R. drawable.Icon);
How does Android call the system's default browser for access?
1. Start the default Android Browser
- Intent intent = new intent ();
- Intent. setaction ("android. Intent. Action. View ");
- Uri content_url = URI. parse ("http://www.cxybl.com ");
- Intent. setdata (content_url );
- Startactivity (intent );
In this way, android can call the default browser to access the mobile phone.
2. Specify the corresponding browser to access
1. Specify the android browser to access
- ("Com. Android. Browser": packagename; "com. Android. browser. browseractivity": Start the main activity)
-
-
- Intent intent = new intent ();
- Intent. setaction ("android. Intent. Action. View ");
- Uri content_url = URI. parse ("http://www.cxybl.com ");
- Intent. setdata (content_url );
- Intent. setclassname ("com. Android. Browser", "com. Android. browser. browseractivity ");
- Startactivity (intent );
-