Open invisible stock activity (ACTION_SEND)

There are many similar questions on StackOverfow, but they do not solve my problem.

The challenge is to handle in service intents sent with the default distribution mechanism (ACTION_SEND) from different applications.
But since it ACTION_SEND

is the action of the action, we must take the intention in our activity and transfer it to the service. And it will be fine if this action is invisible to the user.

I've researched a lot and tried many solutions already.

  • The first step in creating invisible activity is the activity type.

    I have tried these values.

    android: theme = "@android: style / Theme.Translucent.NoTitleBar"

    Android: theme = "@ android: style /Theme.Translucent"

    Android: theme = "@ android: style /Theme.Translucent.NoTitleBar.Fullscreen"

    Also I tried to create a custom theme.

    <style name="Theme.Transparent" parent="android:Theme">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:backgroundDimEnabled">true</item>
    </style>
    
          

    What the action looks like in AndroidManifest.xml.

    <activity
        android:name="xxx.xxx.activities.HandleShareIntentActivity"
        android:theme="@style/Theme.Transparent"
        android:noHistory="true"
        android:excludeFromRecents="true"
        android:label="@string/title_activity_handle_share_intent">
       <intent-filter>
           <action android:name="com.google.android.gm.action.AUTO_SEND"/>
           <action android:name="android.intent.action.SEND"/>
           <action android:name="android.intent.action.SEND_MULTIPLE"/>
           <category android:name="android.intent.category.DEFAULT"/>
           <category android:name="com.google.android.voicesearch.SELF_NOTE"/>
           <data android:mimeType="*/*"/>
       </intent-filter>
    </activity>
    
          

  • Operation code. No setContentView()

    . finish()

    in onCreate()

    .

    public class HandleShareIntentActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            startService(new Intent(this, xxxService.class).putExtra(
            Constants.ACTION_SHARE_KEY, getIntent()));
    
            finish();
        }  
     }
    
          

In Nexus 5, android 4.4.4 I have a black screen flashing when working with any event. Any solutions?

+3


source to share


2 answers


I have tried these values.



Use Theme.NoDisplay

.

+3


source


I just did this and it helped in my case:

<activity
    android:name=".SensorBoardActivity"
    android:theme="@android:style/Theme.NoDisplay"
    android:excludeFromRecents="true"
    android:noHistory="true">

      



I see that you already have it finish();

, but it is only important for others to complete it before leaving onCreate()

.

0


source







All Articles