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