0

My Android app start with a Service.

I am looking at URL schemes. While I had no problem setting this up (data android:scheme="abc"), it appears calling "abc://" from the browser does not work, and I can't find anything in Logcat.

    <service
        android:name="com.xyz.abcService"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
        </intent-filter>
        <meta-data
            android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/voice_trigger_start" />
        <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="abc" />
        </intent-filter>  
    </service>

Prior to adding an intent-filter to the Manifest file, it looked like:

    <service
        android:name="com.xyz.abcService"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:enabled="true"
        android:exported="true">
        <intent-filter>
            <action android:name="com.google.android.glass.action.VOICE_TRIGGER" />
        </intent-filter>
        <meta-data
            android:name="com.google.android.glass.VoiceTrigger"
            android:resource="@xml/voice_trigger_start" />
    </service>

Even when removing the voice trigger, I could not launch abc.

That being said, I had no issue when calling an Activity.

Is anybody aware of any restriction around that?

gdoubleu
  • 72
  • 1
  • 7
  • Essentially, what is after the URL scheme (e.g.: "open") is irrelevant as you do not get into the app at all, I have tried :) – gdoubleu Jul 25 '14 at 15:56

2 Answers2

1

What I did is simply created a new Activity, and have the intent plugged to the Activity.

    <activity
        android:name="com.xyz.launcher.LauncherActivity"
        android:label="@string/app_name"
        android:enabled="true">  
        <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="abc" />
        </intent-filter>          
    </activity>

In turn the Activity calls the Service.

package com.xyz.launcher;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.xyz.abcService;

public class LauncherActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent serviceIntent = new Intent(this, abcService.class);
        startService(serviceIntent);
    }

}

From a user perspective, it makes no difference visually.

gdoubleu
  • 72
  • 1
  • 7
0

When using a scheme it follows the format:

<scheme_value_that_matches_activity_scheme>://<action_name><optional_parameters>

Did you enter anything else after 'abc://'? From what I've understood you then enter what kind of action you want to perform, e.g. 'open'. It would then look like 'abc://open'. I haven't tried it out for myself, but that might be a way to fix it.

Source: Beginning Google Glass Development by Jeff Tang, p. 314-315

Raikso
  • 26
  • 1