2012-06-19 31 views
11
<action android:name="android.intent.action.SEND" />  
<category android:name="android.intent.category.DEFAULT" /> 
<data android:mimeType="text/plain" /> 

這是我的清單文件如何使我的Android應用程序出現在其他特定應用

這會讓我的應用程序出現在所有的應用程序 的共享列表上的共享列表,但我想我的應用程序出現在另一個特定的應用程序 的份額列表中,我不擁有其他應用程序

回答

5

爲了做到這一點,您需要知道應用程序正在創建的Intent,並創建一個IntentFilter來將您的應用程序添加到特定列表中。

Receiving an Implicit IntentIntents and Filters (Android Developers)

應用程序可能使用,你可以鉤到一個特定的動作名稱。

<intent-filter . . . > 
    <action android:name="com.example.project.SHOW_CURRENT" /> 
    <action android:name="com.example.project.SHOW_RECENT" /> 
    <action android:name="com.example.project.SHOW_PENDING" /> 
    . . . 
</intent-filter> 

或者它可能正在尋找應用程序接受某種類型的文件。

<intent-filter . . . > 
    <data android:mimeType="video/mpeg" android:scheme="http" . . . /> 
    <data android:mimeType="audio/mpeg" android:scheme="http" . . . /> 
    . . . 
</intent-filter> 

應用程序的名稱和它共享的內容將幫助我給出更具體的響應。

+2

我希望我的應用僅出現在「Google Play應用」的共享列表中。當你嘗試分享應用程序。它共享文本,但很多其他應用程序使用相同的東西! 我可以過濾文本的內容?? !! –

+1

我不認爲這是可能的。檢查意圖顯示它確實非常普遍。 – DanO

0

我會檢查是否有任何API您想與此應用程序一起工作。

如果是這樣,你可以通過了解

  • 更具體的含蓄的行動爲您的過濾器中受益
  • 或者是添加除默認
  • 其他類別如果你能找到這樣的,這將是不可能的被其他應用看到。

    4

    添加到您的mainefist文件

    <activity android:name=".ShareActivity"> 
    <intent-filter 
        android:label="Share with my app"> 
        <action android:name="android.intent.action.SEND" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
    </intent-filter> 
    

    this link may help you

    +1

    這個標籤幫了我很多!謝謝! –

    4

    這個工作很適合我了讓所有網頁,爲my app,對於MP3文件掃描網頁上,和設置它們的警報。它開闢了我的新URL活動,當您共享網頁:

    下面是在這段代碼的結果: enter image description here

    <activity 
         android:name=".NewUrl" 
         android:label="@string/title_activity_new_url" 
         android:windowSoftInputMode="stateUnchanged"> 
         <intent-filter> 
          <action android:name="android.intent.action.SEND"/> 
          <category android:name="android.intent.category.DEFAULT"/> 
          <data android:mimeType="text/*"/> 
         </intent-filter> 
        </activity> 
    

    然後接收應用程序的鏈接,我從要命的信息本教程: http://code.tutsplus.com/tutorials/android-sdk-receiving-data-from-the-send-intent--mobile-14878

    相關問題