Juned Lanja
Juned Lanja

Reputation: 1474

App as a website launcher

I have a requirement in which i want to make a app that will launch my website and close down. How to achieve this?

    package com.example.myappname;

    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;

    public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("myweburl"));
        startActivity(myIntent);
        finish();
    }
}

My website is opening in browser but app still shows in current open app list .I want to shutdown app as soon as it opens url in browser.

Upvotes: 0

Views: 71

Answers (1)

Vinay W
Vinay W

Reputation: 10190

It sounds like you want your app to not show up in the recent apps list. To do that use the android:excludeFromRecents in your manifest for the activity you are launching the website from

<activity
        android:name=".Activity"
        android:excludeFromRecents="true" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Read more about the android:excludeFromRecents attribute here

Upvotes: 1

Related Questions