Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list application in Android chooser list as an email client? [duplicate]

I am trying to add my Android application in Chooser list as an Email client. However it's not showing up along side Gmail and K-9 application. To test it I am trying to share chat data from whatsapp application chat's "Email chat" feature(As it only shows email apps).

I have only one activity. My application is in chooser list when I share text data from browser but not when I share email data from Whatsapp. I tried adding following intent action my AndroidManifest.xml but it don't work.

        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
            <data android:mimeType="text/*" />
        </intent-filter>

From debug, I found that K-9 is being launch as follows,

08-30 00:27:28.064 489-2302/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
08-30 00:27:28.064 1685-2620/? I/ActivityManager: START u0 {act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras)} from uid 10158 on display 0
08-30 00:27:28.064 489-24642/? I/Thermal-Lib: Thermal-Lib-Client: Client request sent
08-30 00:27:28.064 753-1089/? I/ThermalEngine: Thermal-Server: Thermal received msg from  override
08-30 00:27:28.077 1685-1997/? W/InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@ee526b6 attribute=null, token = android.os.BinderProxy@4b533a5
08-30 00:27:28.177 1685-1749/? I/LaunchCheckinHandler: Displayed android/com.android.internal.app.ChooserActivity,wp,ca,96
08-30 00:27:28.177 1685-1749/? I/ActivityManager: Displayed android/com.android.internal.app.ChooserActivity: +96ms
08-30 00:27:28.244 1685-1845/? D/MotoSensors: ALS 41
08-30 00:27:28.253 1685-1694/? I/art: Background partial concurrent mark sweep GC freed 57795(3MB) AllocSpace objects, 27(1060KB) LOS objects, 30% free, 36MB/52MB, paused 2.148ms total 160.734ms
08-30 00:27:28.306 9905-9979/? D/OpenGLRenderer: endAllActiveAnimators on 0x8ea64500 (aq$a) with handle 0x8ee25d30
08-30 00:27:28.307 1685-2108/? I/WindowManager: Destroying surface Surface(name=PopupWindow:dcadc74) called by com.android.server.wm.WindowStateAnimator.destroySurface:2067 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:896 com.android.server.wm.WindowState.removeLocked:1457 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2546 com.android.server.wm.WindowManagerService.removeWindowLocked:2504 com.android.server.wm.WindowManagerService.removeWindowLocked:2373 com.android.server.wm.WindowManagerService.removeWindow:2364 com.android.server.wm.Session.remove:193 
08-30 00:27:28.553 585-645/? I/SFPerfTracer:      triggers: (rate: 14:1327) (1008781 sw vsyncs) (0 skipped) (42:3589810 vsyncs) (44:4764825)
08-30 00:27:28.707 585-585/? I/SFPerfTracer:      triggers: (rate: 2783:527680) (compose: 1:238) (post: 3:2376) (render: 6:1240) (3:1974551 frames) (4:2171862)
08-30 00:27:28.707 585-585/? D/SFPerfTracer:        layers: (5:12) (DimLayerController/Stack=0 (0xae241400): 1:9571) (StatusBar (0xae243c00): 4:397491) (com.android.systemui.ImageWallpaper (0xacfb7400): 4:264193)* (Sprite (0xae23ec00): 0:863)* (animation background stackId=1 (0xacfb9c00): 0:1482)* (animation background stackId=0 (0xacfd9c00): 0:12)* (NavigationBar (0xacfb6000): 4:252) (com.whatsapp/com.whatsapp.Conversation (0xacfd6000): 4:230) (PopupWindow:e9ad06f (0xacfb8800): 0:44)- (PopupWindow:dcadc74 (0xacfd7400): 0:44)- (Initializing... (0xacfb8800): 0:2)- (android/com.android.internal.app.ChooserActivity (0xacfb8800): 4:28) 
08-30 00:27:29.343 1685-2562/? I/ActivityManager: START u0 {act=android.intent.action.SEND_MULTIPLE typ=text/* flg=0xb080001 pkg=com.fsck.k9 cmp=com.fsck.k9/.activity.MessageCompose clip={text/* U:content://com.whatsapp.fileprovider/external/WhatsApp/.Shared/WhatsApp%20Chat%20with%20%E2%80%AA%2B91%2096019%2049744%E2%80%AC.txt} (has extras)} from uid 10158 on display 0

I also put type=text/* in my intent-filter, however my app is not listed. Any idea why? What can I do to list it?

like image 562
Sunil Shahu Avatar asked Aug 29 '17 19:08

Sunil Shahu


People also ask

Which of the following will force the app chooser to show?

You have to run lab3a_MyBrowser before you run lab3a_IntentsLab , so that the browser gets installed on your phone. Then it will be visible to your chooser.

What is startActivity in Android?

Starting activities or services. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent.

How can I transfer data from one app to another in Android?

Android uses the action ACTION_SEND to send data from one activity to another, even across process boundaries. You need to specify the data and its type. The system automatically identifies the compatible activities that can receive the data and displays them to the user.

How can two different Android applications interact explain in detail?

To take the user from one activity to another, your app must use an Intent to define your app's "intent" to do something. When you pass an Intent to the system with a method such as startActivity() , the system uses the Intent to identify and start the appropriate app component.


1 Answers

I pulled these intent filters straight out of the Gmail APK.

This intent filter handles mailto links.

<intent-filter>

    <action
        android:name="android.intent.action.SENDTO" />

    <action
        android:name="android.intent.action.VIEW" />

    <category
        android:name="android.intent.category.DEFAULT" />

    <category
        android:name="android.intent.category.BROWSABLE" />

    <data
        android:scheme="mailto" />
</intent-filter>

This one allows to process mailto intents discovered via NFC.

<intent-filter>

    <action
        android:name="android.nfc.action.NDEF_DISCOVERED" />

    <category
        android:name="android.intent.category.DEFAULT" />

    <data
        android:scheme="mailto" />
</intent-filter>

This one allows to open your app as a response to SEND intents and the "Ok Google, note to self" voice command.

<intent-filter>

    <action
        android:name="android.intent.action.SEND" />

    <category
        android:name="android.intent.category.DEFAULT" />

    <category
        android:name="com.google.android.voicesearch.SELF_NOTE" />

    <data
        android:mimeType="*/*" />
</intent-filter>

This one allows to send multiple items (represented by Uris) at once.

<intent-filter>

    <action
        android:name="android.intent.action.SEND_MULTIPLE" />

    <category
        android:name="android.intent.category.DEFAULT" />

    <data
        android:mimeType="*/*" />
</intent-filter>

There were two more specific to Gmail domain which are not relevant and I've left out.

To verify yourself:

  1. Obtain a Gmail APK.
  2. In Android Studio go to Main Menu > Build > Analyze APK...
  3. Find and open the Gmail APK using the file picker.
  4. Select AndroidManifest.xml in the APK Analyzer.

Processing the intents once they're delivered to your app is out of the scope.

like image 167
Eugen Pechanec Avatar answered Sep 20 '22 19:09

Eugen Pechanec