mlecar
mlecar

Reputation: 829

Execute an action without opening application in Android

I have an application in Android that has a button in the MAIN activity that performs an action.

Is there a way to execute that action without opening the application?

I don't know if I can say it is like a widget, because it does not wait for updates.

The user should be able to execute that action just clicking on the icon of the application without opening. Is it possible?

Upvotes: 1

Views: 358

Answers (2)

Phil Lello
Phil Lello

Reputation: 8639

Yes and no. What I had to do for a similar problem was have a transparent view in my main activity, and then self-terminate:

In your activity...

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
            // Do whatever you need here...
    finish();
}

And in AndroidManifest.xml:

        <activity android:name=".whatever" android:theme="@android:
style/Theme.NoDisplay">

Hope this helps,

Phil Lello

Upvotes: 4

Related Questions