Is there any way to put extras to Intent from preferences?

后端 未结 8 681
广开言路
广开言路 2020-12-13 08:42

Hi i\'m launching activity from preferences screen. Activity is shared among three preferences. I wonder if i can set extras for this activity in xml



        
相关标签:
8条回答
  • 2020-12-13 09:10

    To send email or rate on market you need to use something like

    <Preference
            android:title="@string/title_intent_preference"
            android:summary="@string/summary_intent_preference">
    
        <intent android:action="android.intent.action.VIEW"
                android:data="market://details?id=com.your_package" />
    
    </Preference>
    <Preference
            android:title="@string/title_intent_preference"
            android:summary="@string/summary_intent_preference">
    
        <intent android:action="android.intent.action.VIEW"
                android:data="mailto:your_email@gmail.com" />
    
    </Preference>
    
    0 讨论(0)
  • 2020-12-13 09:11

    There is a data field for intents described in the documentation here.

    It is used in the API demo application for the XML preferences to launch an intent in the Intent Preferences example.

    Related example xml from that demo in preferences.xml:

        <PreferenceScreen
                android:title="@string/title_intent_preference"
                android:summary="@string/summary_intent_preference">
    
            <intent android:action="android.intent.action.VIEW"
                    android:data="http://www.android.com" />
    
        </PreferenceScreen>
    

    Maybe this approach could work for you?

    0 讨论(0)
提交回复
热议问题