Home > front end >  Android/Java: How to create personalized schemes without https in it?
Android/Java: How to create personalized schemes without https in it?

Time:05-26

How to use schemes with parameters without using https ? It works only with https, I would like to use other piece of code for example opening the app with the url :

myapp://open

Here is my actual code:

  <intent-filter
        android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />


        <data android:scheme="https" android:host="open" />

    </intent-filter>

I tried <data android:scheme="myapp" android:host="open" /> but doesn't work. I tried in Google Lens (and other scan app) that doesn't make me opening schemes that doesn't contain "https"

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="33"/> <!-- NEW CODE -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CAMERA2" />
    <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" tools:ignore="ProtectedPermissions" />
    <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION"/>
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

Thank you

CodePudding user response:

You seem to require at least a custom scheme and host like the following example:

<activity ... exported=true>
    <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="myapp" android:host="open" />
    </intent-filter>
</activity>

You can test it using

adb shell am start -W -a android.intent.action.VIEW -d myapp://open

By executing this command the activity that is associated with the intent-filter will open.

If it still doesn't work then may be the used QR code reader is not usuable with custom schemes. For example the open source app Binary Eye (de.markusfisch.android.binaryeye) has no problem opening an app using a QR code with a link myapp://open.

  • Related