Call the built-in browser in APK

Source: Internet
Author: User

I have found two methods, which are summarized as follows:

 

Method 1:

 

Uri uri = URI. parse ("http://blog.csdn.net/u0fly"); <br/> intent it = new intent (intent. action_view, Uri); <br/> startactivity (it );


Method 2:


Intent mintent = new intent (); <br/> componentname comp = new componentname ("com. android. browser "," com. android. browser. browseractivity "); <br/> mintent. setcomponent (COMP); <br/> mintent. setaction ("android. intent. action. main "); <br/> startactivity (mintent );


Method 1 can specify the page to open.


Another way is to open a webpage in the form of webview in the current program window.

Note: you must add <uses-Permission Android: Name = "android. Permission. Internet"/> to androidmanifest. xml.


Main. xml

Add:

<Webview Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent" Android: Id = "@ + ID/WV"/>

Main Program:

Add:

Final Activity activity = This; </P> <p> webview WV = (webview) This. findviewbyid (R. id. WV); <br/> WV. getsettings (). setjavascriptenabled (true); </P> <p> WV. setwebchromeclient (New webchromeclient () {<br/> Public void onprogresschanged (webview view, int progress) {<br/> // activities and webviews measure progress with different scales. <br/> // The Progress Meter will automatically disappear when we reach 1 00% <br/> activity. setprogress (Progress * 1000); <br/>}< br/>}); </P> <p> WV. setwebviewclient (New webviewclient () {<br/> Public void onreceivederror (webview view, int errorcode, string description, string failingurl) {<br/> toast. maketext (activity, "Oh no! "+ Description, toast. length_short ). show (); <br/>}< br/>}); </P> <p> WV. loadurl ("http://www.google.com ");
 


Intent Summary by netizens

 

1. Search for content from Google

Intent intent = new intent ();

Intent. setaction (intent. action_web_search );

Intent. putextra (searchmanager. query, "searchstring ")

Startactivity (intent );

2. Browse the webpage

Uri uri = URI. parse ("http://www.google.com ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

3. display a map

Uri uri = URI. parse ("Geo: 38.899533,-77.036476 ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

4. Route Planning

Uri uri = URI. parse ("http://maps.google.com/maps? F = dsaddr = startlat % 20 startlng & daddr = endlat % 20 endlng & HL = EN ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

5. Call

Uri uri = URI. parse ("Tel: xxxxxx ");

Intent it = new intent (intent. action_dial, Uri );

Startactivity (it );

6. Call the SMS Program

Intent it = new intent (intent. action_view );

It. putextra ("sms_body", "the SMS text ");

It. settype ("Vnd. Android-DIR/MMS-SMS ");

Startactivity (it );

7. send SMS

Uri uri = URI. parse ("smsto: 0800000123 ");

Intent it = new intent (intent. action_sendto, Uri );

It. putextra ("sms_body", "the SMS text ");

Startactivity (it );

String body = "this is SMS Demo ";

Intent mmsintent = new intent (intent. action_sendto, Uri. fromparts ("smsto", number, null ));

Mmsintent. putextra (messaging. key_action_sendto_message_body, body );

Mmsintent. putextra (messaging. key_action_sendto_compose_mode, true );

Mmsintent. putextra (messaging. key_action_sendto_exit_on_sent, true );

Startactivity (mmsintent );

8. Send MMS

Uri uri = URI. parse ("content: // media/external/images/Media/23 ");

Intent it = new intent (intent. action_send );

It. putextra ("sms_body", "some text ");

It. putextra (intent. extra_stream, Uri );

It. settype ("image/PNG ");

Startactivity (it );

Stringbuilder sb = new stringbuilder ();

SB. append ("file ://");

SB. append (FD. getabsolutefile ());

Intent intent = new intent (intent. action_sendto, Uri. fromparts ("mmsto", number, null ));

// Below extra datas are all optional.

Intent. putextra (messaging. key_action_sendto_message_subject, subject );

Intent. putextra (messaging. key_action_sendto_message_body, body );

Intent. putextra (messaging. key_action_sendto_content_uri, SB. tostring ());

Intent. putextra (messaging. key_action_sendto_compose_mode, composemode );

Intent. putextra (messaging. key_action_sendto_exit_on_sent, exitonsent );

Startactivity (intent );

9. Send email

Uri uri = URI. parse ("mailto: xxx@abc.com ");

Intent it = new intent (intent. action_sendto, Uri );

Startactivity (it );

Intent it = new intent (intent. action_send );

It. putextra (intent. extra_email, "me@abc.com ");

It. putextra (intent. extra_text, "the email body text ");

It. settype ("text/plain ");

Startactivity (intent. createchooser (IT, "Choose email client "));

Intent it = new intent (intent. action_send );

String [] TOS = {"me@abc.com "};

String [] CCS = {"you@abc.com "};

It. putextra (intent. extra_email, TOS );

It. putextra (intent. extra_cc, CCS );

It. putextra (intent. extra_text, "the email body text ");

It. putextra (intent. extra_subject, "the email subject text ");

It. settype ("message/rfc822 ");

Startactivity (intent. createchooser (IT, "Choose email client "));

Intent it = new intent (intent. action_send );

It. putextra (intent. extra_subject, "the email subject text ");

It. putextra (intent. extra_stream, "file: // sdcard/mysong.mp3 ");

Sendintent. settype ("audio/MP3 ");

Startactivity (intent. createchooser (IT, "Choose email client "));

10. Play multimedia

Intent it = new intent (intent. action_view );

Uri uri = URI. parse ("file: // sdcard/song.mp3 ");

It. setdataandtype (Uri, "audio/MP3 ");

Startactivity (it );

Uri uri = URI. withappendedpath (mediastore. Audio. Media. internal_content_uri, "1 ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

11. Uninstall APK

Uri uri = URI. fromparts ("package", strpackagename, null );

Intent it = new intent (intent. action_delete, Uri );

Startactivity (it );

12. Install APK

Uri installuri = URI. fromparts ("package", "XXX", null );

Returnit = new intent (intent. action_package_added, installuri );



13. Open the camera

<1> intent I = new intent (intent. action_camera_button, null );

This. sendbroadcast (I );

<2> long datetaken = system. currenttimemillis ();

String name = createname (datetaken) + ". jpg ";

Filename = folder + name;

Contentvalues values = new contentvalues ();

Values. Put (images. Media. Title, filename );

Values. Put ("_ data", filename );

Values. Put (images. Media. picasa_id, filename );

Values. Put (images. Media. display_name, filename );

Values. Put (images. Media. Description, filename );

Values. Put (images. imagecolumns. bucket_display_name, filename );

Uri photouri = getcontentresolver (). insert (

Mediastore. Images. Media. external_content_uri, values );



Intent inttphoto = new intent (mediastore. action_image_capture );

Inttphoto. putextra (mediastore. extra_output, photouri );

Startactivityforresult (inttphoto, 10 );

14. Select an image from gallery

Intent I = new intent ();

I. settype ("image /*");

I. setaction (intent. action_get_content );

Startactivityforresult (I, 11 );

15. Enable the recorder

Intent MI = new intent (media. record_sound_action );

Startactivity (MI );

16. display the detailed list of applications

Uri uri = URI. parse ("Market: // details? Id = app_id ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

// Where app_id is the Application ID, find the ID

// By clicking on your application on market Home

// Page, and notice the ID from the address bar

Failed to find the app Id just now. It turns out that the package name can also be used.

Uri uri = URI. parse ("Market: // details? Id = <packagename> ");

This is much simpler.

17. Search for Applications

Uri uri = URI. parse ("Market: // search? Q = pname: pkg_name ");

Intent it = new intent (intent. action_view, Uri );

Startactivity (it );

// Where pkg_name is the full package path for an application

18 open the contact list

<1>

Intent I = new intent ();

I. setaction (intent. action_get_content );

I. settype ("Vnd. Android. cursor. Item/phone ");

Startactivityforresult (I, request_text );

<2>

Uri uri = URI. parse ("content: // contacts/People ");

Intent it = new intent (intent. action_pick, Uri );

Startactivityforresult (it, request_text );

19 open another program

Intent I = new intent ();

Componentname Cn = new componentname ("com. yellowbook. android2 ",

"Com. yellowbook. android2.androidsearch ");

I. setcomponent (CN );

I. setaction ("android. Intent. Action. Main ");

Startactivityforresult (I, result_ OK );

★Intent action Daquan:

  • Android. Intent. Action. all_apps
  • Android. Intent. Action. Answer
  • Android. Intent. Action. attach_data
  • Android. Intent. Action. bug_report
  • Android. Intent. Action. Call
  • Android. Intent. Action. call_button
  • Android. Intent. Action. chooser
  • Android. Intent. Action. create_live_folder
  • Android. Intent. Action. create_shortcut
  • Android. Intent. Action. Delete
  • Android. Intent. Action. Dial
  • Android. Intent. Action. Edit
  • Android. Intent. Action. get_content
  • Android. Intent. Action. insert
  • Android. Intent. Action. insert_or_edit
  • Android. Intent. Action. Main
  • Android. Intent. Action. media_search
  • Android. Intent. Action. Pick
  • Android. Intent. Action. pick_activity
  • Android. Intent. Action. ringtone_picker
  • Android. Intent. Action. Run
  • Android. Intent. Action. Search
  • Android. Intent. Action. search_long_press
  • Android. Intent. Action. Send
  • Android. Intent. Action. sendto
  • Android. Intent. Action. set_wallpaper
  • Android. Intent. Action. sync
  • Android. Intent. Action. system_tutorial
  • Android. Intent. Action. View
  • Android. Intent. Action. voice_command
  • Android. Intent. Action. web_search
  • Android.net. Wifi. pick_wifi_network
  • Android. settings. airplane_mode_settings
  • Android. settings. apn_settings
  • Android. settings. application_development_settings
  • Android. settings. application_settings
  • Android. settings. effecth_settings
  • Android. settings. data_roaming_settings
  • Android. settings. date_settings
  • Android. settings. display_settings
  • Android. settings. input_method_settings
  • Android. settings. internal_storage_settings
  • Android. settings. locale_settings
  • Android. settings. location_source_settings
  • Android. settings. manage_applications_settings
  • Android. settings. memory_card_settings
  • Android. settings. network_operator_settings
  • Android. settings. quick_launch_settings
  • Android. settings. security_settings
  • Android. settings. Settings
  • Android. settings. sound_settings
  • Android. settings. sync_settings
  • Android. settings. user_dictionary_settings
  • Android. settings. wifi_ip_settings
  • Android. settings. wifi_settings
  • Android. settings. wireless_settings


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.