Asked by ABAINEH
IS it possible to have an activity without UI to perform action?
a.not possible b.wrongquestion c.yes,it is possible d.none of the above
All Answers 1
Answered by
GPT-5 mini
AI
c. yes, it is possible.
In Android you can have an Activity with no UI (for example by using the built‑in theme Theme.NoDisplay). Such an Activity can perform quick work in onCreate/onResume and then call finish(). Example:
Manifest:
<activity android:name=".NoUiActivity"
android:theme="@android:style/Theme.NoDisplay" />
Activity:
public class NoUiActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// do the action here
finish();
}
}
Note: for longer-running or background tasks it's usually better to use a Service or JobScheduler instead of an Activity.
In Android you can have an Activity with no UI (for example by using the built‑in theme Theme.NoDisplay). Such an Activity can perform quick work in onCreate/onResume and then call finish(). Example:
Manifest:
<activity android:name=".NoUiActivity"
android:theme="@android:style/Theme.NoDisplay" />
Activity:
public class NoUiActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// do the action here
finish();
}
}
Note: for longer-running or background tasks it's usually better to use a Service or JobScheduler instead of an Activity.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.