2017-01-02 4 views
0

私は、暗黙インテントを使用してブラウザ内でリンクを開くために、Courseraの割り当てに取り組んでいます。コード内には、使用したいブラウザのオプションを与える選択メソッドがあります。しかし問題は、CATEGORY Browsableオプションを使用してブラウザが表示されないことです。 (何のブラウザが出てくるんなぜ私は理解していない)ブラウザ内でリンクを開く意図がありません

private void startImplicitActivation() { 

     Log.i(TAG, "Entered startImplicitActivation()"); 

     // TODO - Create a base intent for viewing a URL 
     // (HINT: second parameter uses Uri.parse()) 


     String url = "https://www.google.com"; 
     Intent baseIntent = new Intent(Intent.CATEGORY_BROWSABLE, Uri.parse(url)); 


     // TODO - Create a chooser intent, for choosing which Activity 
     // will carry out the baseIntent 
     // (HINT: Use the Intent class' createChooser() method) 
     Intent chooserIntent = new Intent(Intent.createChooser(baseIntent, "Select Your Browser")); 


     Log.i(TAG,"Chooser Intent Action:" + chooserIntent.getAction()); 


     // TODO - Start the chooser Activity, using the chooser intent 
     startActivity(chooserIntent); 


} 

活動に発売された出力は以下の通りです:私のコードを見てください

createChooser() method called with intent

+1

[特定のURLを開くためのブラウザへのインテントの送信](http://stackoverflow.com/questions/3004515/sending-an-intent-to-browser-to-open-specific-url) – AxelH

答えて

0

あなたがこれを使用することができます:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("your url")); 
startActivity(intent); 

あなたの携帯電話にブラウザがインストールされていることを示すコードが直接ポップアップ表示されると思います。あなたはそのための特定のコードを書いていません。

関連する問題