2017-12-18 328 views
0

我已經構建了一個Android瀏覽器,我想從其他應用程序加載外部網絡鏈接。在這裏,我在AndroidManifest.xml上添加了這段代碼。所以當我從其他應用打開http/https鏈接時,它會在瀏覽器列表中顯示我的應用。從其他應用程序加載到我的瀏覽器的外部網絡鏈接

<intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data android:scheme="http" /> 
      <data android:scheme="https" /> 
     </intent-filter> 

現在,通過鍵名,我將獲得這些數據到我的瀏覽器??? 想,如果我發送一個網絡鏈接,關鍵是「URL」,然後我可以加載這個方式,網址,

Intent intent = getIntent(); 
    String url = intent.getStringExtra("url"); 

    if(url!=null) { 
     Intent i = new Intent(Intent.ACTION_VIEW); 
     i.setData(Uri.parse(url)); 
     startActivity(i); 
     finish(); 
    } 

我不知道由哪個鍵名其他應用程序是將數據發送到打開與外部瀏覽器。我該如何解決這個問題?

+0

你想在你的瀏覽器中打開url嗎? – R2R

+0

是的。但我可以捕捉到鏈接? (通過哪個鍵名) – abir99

回答

相關問題