Is it in any way possible to launch an activity from the main function without having a UI? i.e. is there a way to create a sort of "wrapper" around another activity, i.e. by launching the main activity, it takes you to another activity automatically.
If that is not possible, is there a way to remove the main activity from the stack so that clicking the back button does not take you to a blank UI? Here's an example of what I'm trying to do:
public class WrapperActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-1212")); startActivity(intent); } }
Explanation. Generally, every activity is having its UI(Layout). But if a developer wants to create an activity without UI, he can do it.
Yes it is. If your requirement are like that then there is no harm in doing that.
Activity instances are always created by the Android system. This is because a lot of initializations have to be done for the activity to work. To create a new activity you call startActivity with an Intent describing the activity to start. To add more to this answer.
Android also provides a theme specifically for this:
android:theme="@android:style/Theme.NoDisplay"
In your manifest, when you declare the activity, use theme "@android:style/Theme.Translucent.NoTitleBar"
Ex:
<activity android:name="yourActivityName" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With