Call the Android system installed software to open the file, the program stops running

Source: Internet
Author: User

Problem description
Title, when you open a file by calling the software installed on the Android system, the program works when the system has software installed, but stops when the system cannot find the software that matches the file type. Now I want to let it not find the corresponding software can prompt the user, instead of directly stop running, code should be how to write, ask great God!!!
Solutions 1
Or catch startactivity exceptions, but this is a rough way. Solutions 2
try {//Put your 7 floor code here} catch (Exception e) {//Prompt user not found}
Solutions 3
Why, just use it.

Gets the Packagemanager object Packagemanager pm = This.getpackagemanager ();        Conditions to be met in Settings <intent-filter> tags intent intent = new Intent (intent.action_main, NULL);        Intent.addcategory (Intent.category_default);        if (intent.resolveactivity (PM)!=null) {startactivity (intent); }else{//Dealing with events that do not have an open program here}


This way, the event can be processed by Intent.resolve and then started, or handled by itself.

Call the Android system installed software to open the file, the program stops running

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.