2011-10-24 81 views
1

嗨自定义网址方案不适合我。这里是我的代码自定义URL方案Android

   <application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".MainActivity" android:label="@string/app_name" 
     android:launchMode="singleTask"> 

     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      <data android:scheme="http" android:host="jinilabs.test" /> 
     </intent-filter> 
    </activity> 

</application> 

,当我在模拟器上的浏览器中键入URL - http://jinilabs.test 这是给我的网页无法使用的错误。 这里有什么不对吗? PLZ让我知道

回答

0

添加该代码清单文件:

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 

,然后尝试。

+0

嗨Ravi,我也补充说过。但即使它不工作 – bheema

+0

请参阅这些答案:1. http://stackoverflow.com/questions/2437366/android-emulator-internet-access 2. http://stackoverflow.com/questions/2206822/no-互联网上的Android模拟器为什么和如何修复 –

+0

嗨拉维,上述链接并没有帮助我。我的网络工作正常,我正在运行三星联盟S. – bheema

3

只需在栏中输入URL即可。您的网址需要是网页上的可点击链接,因为浏览器方法会检查该网址是否为自定义网址,并且只会在点击链接时触发;它只是运行在地址栏中输入的网址(并忽略自定义网址)。 点击this link应该立即启动您的应用。如果它仍然不起作用,您可能需要清单文件中的其他代码。矿看起来是这样的:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="appcall.thing" 
    android:versionCode="1" 
    android:versionName="1.0"> 
    <uses-sdk android:minSdkVersion="4" /> 

<application android:icon="@drawable/icon" android:label="@string/app_name"> 
    <activity android:name=".AppCallActivity" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

     <intent-filter> 
      <data android:scheme="stoneware.app.switcher" /> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT"/> 
      <category android:name="android.intent.category.BROWSABLE"/> 
     </intent-filter> 
    </activity> 
</application> 
</manifest> 

当然,你将不得不替换这里的一些名称相对于您的应用程序的名称。我还建议开始你的url方案,使用一些独特的东西而不是http,以防http混淆浏览器。我的url方案,例如stoneware.app.switcher:// 希望这可以对你有些用处:)

+0

非常感谢这篇文章,我在寻找解决方案之后怀疑它为什么不能从浏览器url中运行。 –

+0

链接不工作:( – SolArabehety