Reputation: 84
I am building a small web app for contact and because some of the data will be access via www i dont want non-android user to go to the site.
my idea is to change the user agent so when i go to the site, i read the user agent and can detect if it comes from the app or not.
here the manifest i have now (copied from the android website)
i have also the assets/www/index.html (and other files there)
is there an option in the manifest to change that?
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<permission android:name="myproject"></permission>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sample" >
<activity
android:name="com.example.android.basiccontactables.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTop">
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 0
Views: 1673
Reputation: 8768
You can't use manifest to change WebView
s user agent. You should use WebSettings
in Java code instead, specifically its setUserAgentString method. Use it something like this:
webView.getSettings().setUserAgentString("Android");
Upvotes: 3