AVD tool / app to monitor or debug INTENT calls

2019-08-25 08:38发布

问题:

Before I start to write one I'm looking for an existing App I can push to an AVD image that will act as a dummy / default receiver for as many of the common mime types as possible.

The idea is to test a successful Share without having to push the build to a physical device or knife and fork a specific app to the emulator. The standard AVD images are brilliant for testing the: "No apps can perform this action" path through my code, but not a positive share.

回答1:

As a stopgap and per my comment above I created a dummy receiver app, based on the tutorialspoint.com example, that would simply display the pased URI.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_custom);

    TextView label = (TextView) findViewById(R.id.show_data);

    Uri url = getIntent().getData();
    label.setText(url.toString());
}

Simply expanded the set of filters in the manifest, to cover most scenarios:

    <activity
        android:name=".CustomActivity"
        android:label="@string/title_activity_custom" >
        <intent-filter>
            <action android:name="com.example.intentdemo.LAUNCH" />
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.EDIT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
            <data android:scheme="https" />
            <data android:scheme="ftp" />
            <data android:scheme="fax" />
            <data android:scheme="tel" />
            <data android:scheme="tv" />
            <data android:scheme="telnet" />
            <data android:scheme="file" />
            <data android:scheme="data" />
            <data android:scheme="im" />
            <data android:scheme="irc" />
            <data android:scheme="gtalk" />
            <data android:scheme="info" />
            <data android:scheme="ldap" />
            <data android:scheme="imap" />
            <data android:scheme="mailto" />
            <data android:scheme="pop" />
            <data android:scheme="skype" />
            <data android:scheme="spotify" />
            <data android:scheme="ssh" />
            <data android:scheme="smb" />
            <data android:scheme="nfs" />
            <data android:scheme="steam" />
        </intent-filter>
    </activity>