In some cases, we may want to open a certain application, for example, we want to open Baidu's site through a browser, but we do not stress the need to use which browser, then this situation we use is not very good, it is better to use the implicit intent to open the site.
Effect:
After clicking the button:
Attached code:
1 Packagecom.yy.activity;2 3 Importandroid.app.Activity;4 Importandroid.content.Intent;5 ImportAndroid.net.Uri;6 ImportAndroid.os.Bundle;7 ImportAndroid.view.View;8 9 Public classMainactivityextendsActivity {Ten One @Override A protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); the } - - /** - * Open Browser with implicit intent + * @paramView - */ + Public voidClick (View view) { A //Intentions atIntent intent=NewIntent (); - //An act of intent, an implicit intention. - intent.setaction (intent.action_view); - //Data of Intent -Intent.setdata (Uri.parse ("http://www.baidu.com")); - //Start in startactivity (intent); - } to}
Android implicitly attempts to activate the browser