0

I've implemented this solution to start a specified Activity from a web browser.

The official Android docs only talk about Activity's as well.

However, the requests are growing and depending on the request, a different Activity needs to be started. I was thinking of an IntentService that figures out what message and based on that, starts a specified Activity. What is the correct way to implement this? Because I tried an IntentService and it doesn't get triggered:

public class APIService extends IntentService {

    public APIService(String name) {
        super(name);
    }

    public APIService() {
        super("");
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "onBind: ");
        return null;
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        Log.d(TAG, "onBind: ");
    }
}

But this solution does not trigger the App anymore.

<service
        android:name=".services.APIService"
        android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="qkey"/>
        </intent-filter>
    </service>
Community
  • 1
  • 1
Jim Clermonts
  • 1,270
  • 6
  • 23
  • 64
  • this is because the browser calls `startActivity`, not `startService`, just make your `Activity` as a proxy that starts the target `Activity` and `finish()`es itself – pskink Aug 11 '16 at 09:23
  • @pskink Okay, I've implemented it as an Activity. – Jim Clermonts Aug 12 '16 at 13:08

0 Answers0