I developed a very simple app which just opens our companies website.
I had to program it in a way, so that it asks the user in which browser he wants to open the website, because WebView is missing some features and has some bugs.
Full code:
package XXX;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class FullscreenActivity extends AppCompatActivity
{
public void openWebPage(String url)
{
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
openWebPage("https://www.example.com");
finish(); // I also tried: System.exit(0);
}
}
The user is getting asked which browser he likes the website to be opened with. After that, the browser opens and loads the website.
Problem: The app is still open, even though I need it to get closed at this point.
How can I close the app after it startet the browser?
I tried finish()
and even System.exit(0)
, both failed.