My own phone (one add-on, upgrade the hydrogen OS), then click on a "Privacy policy" in the game--need to open a webpage and then crash. The error message is as follows:
It was completely invisible, and then I wrote a demo to test the code and found the details of the error:
09-29 11:45:27.576:e/androidruntime (17871): Android.content.ActivityNotFoundException:No Activity found to handle Intent {act=android.intent.action.view cat=[android.intent.category.browsable] dat=http://url typ=text/html}
Not able to respond to the specified intent activity, but my phone to view the subscription number of the article, click on the upper right corner "open in the browser", is can pop-up to select the browser interface, normal.
A total of a few pieces of code, I analyzed, and then found the problem:
@Override
protectedvoidOnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Button Btnopenbrowser = (button) Findviewbyid (R.id.btn_open_browser);
Btnopenbrowser.setonclicklistener (NewOnclicklistener () {
@Override
PublicvoidOnClick (View v) {
//TODO auto-generated method stub
LOG.I ("Meteoric","click");
String strURL ="Http://cdn.haowanyou.com/mobile/comm/gtqz/yhxy.html";
Uri uri = Uri.parse (strURL);
Intent Intent =NewIntent (Intent.action_view);
Intent.addcategory (intent.category_browsable);
Intent.setdata (URI);
//Intent.setdataandtype (URI, "text/html");
StartActivity (Intent);
}
});
}
The code that is commented out is the place that produces crash, the change place is to replace Setdataandtype method with SetData. When the specified MIME type is text/html, no activity can respond. The DAT is followed by a parameter called Typ, which means that no activity can capture the intent of Typ as text/html.
In fact, it is best when startactivity, can try catch, when the specified Mimie type is a mailbox, the phone is not installed on the mailbox client will be crash. In view of the MIME problem, I temporarily just removed the type, the company test group over 5.0 of the device test is not my problem, not sure is the problem of hydrogen OS, or all 5.0 systems are so, interested students can self-test.
Android calls browser open URLs encountered problems