Execute an action without opening application in Android
开发者_JAVA技巧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?
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
Try this question Android - How to execute main functionality of project only by clicking on the icon of application?
精彩评论