简体   繁体   中英

How can I finish an activity in android tv project

I have an android tv that chrome has installed on it. My only problem is I want to create an app that when I try to open it it will open google chrome. not opening settings then selecting app then open in chrome section. I've made that and it's working but when it's started google chrome activity it won't close it self.

Think that I'm using just finish code but not working. (It will work but it wont close the application so I can see it's running in background)

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getPackageManager().getLaunchIntentForPackage("com.android.chrome");

        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);

    }

I expected it should close the processor but it didn't.

I've tried:

finish();
System.exit(0);

and it's worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM