Android: Adding data to Intent fails to load Activity

前端 未结 1 1260
予麋鹿
予麋鹿 2021-02-10 07:44

I have a widget that supposed to call an Activity of the main app when the user clicks on widget body. My setup works for a single widget instance but for a second instance of t

相关标签:
1条回答
  • 2021-02-10 07:48

    I think you need a <data> tag in your <intent-filter> in order for the intent you are firing to match the intent-filter you have registered.

    https://developer.android.com/guide/topics/manifest/data-element.html

    Also using Uri.EMPTY may be a problem. I'd create your own Uri scheme, so that your setData() call looks something like:

    di.setData(Uri.withAppendedPath(Uri.parse("droidln://widget/id/"), String.valueOf(appWidgetId)));
    

    and your intent-filter would look like:

        <intent-filter>
            <action android:name="bostone.android.search.RESULTS" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="droidln"/>
        </intent-filter>
    
    0 讨论(0)
提交回复
热议问题